Only seed database for Debian install if we're using default config
[onak.git] / parsekey.h
1 /*
2  * parsekey.h - Routines to parse an OpenPGP key.
3  *
4  * Jonathan McDowell <noodles@earth.li>
5  *
6  * Copyright 2002 Project Purple
7  */
8
9 #ifndef __PARSEKEY_H__
10 #define __PARSEKEY_H__
11
12 #include "keystructs.h"
13
14 /**
15  *      parse_keys - Process a stream of packets for public keys + sigs.
16  *      @packets: The packet list to parse.
17  *      @keys: The returned list of public keys.
18  *
19  *      This function takes an list of OpenPGP packets and attempts to parse it
20  *      into a list of public keys with signatures and subkeys.
21  *
22  *      Returns a count of how many keys we parsed.
23  */
24 int parse_keys(struct openpgp_packet_list *packets,
25                 struct openpgp_publickey **keys);
26
27 /**
28  *      debug_packet - Print debug info about a packet
29  *      @packet: The packet to display.
30  *
31  *      This function takes an OpenPGP packet and displays some information
32  *      about it to stdout. Useful for debugging purposes or curiousity about
33  *      an OpenPGP packet stream.
34  */
35 int debug_packet(struct openpgp_packet *packet);
36
37 /**
38  *      read_openpgp_stream - Reads a stream of OpenPGP packets.
39  *      @getchar_func: The function to get the next character from the stream.
40  *      @ctx: A pointer to the context structure for getchar_func.
41  *      @packets: The outputted list of packets.
42  *      @maxnum: The maximum number of keys to read. 0 means unlimited.
43  *
44  *      This function uses getchar_func to read characters from an OpenPGP
45  *      packet stream and reads the packets into a linked list of packets
46  *      ready for parsing as a public key or whatever. maxnum allows you to
47  *      specify the maximum number of keys to read. Note that if this is used
48  *      then only the public key component of the last key will be returned,
49  *      none of the other packets of the key will be read.
50  */
51 int read_openpgp_stream(int (*getchar_func)(void *ctx, size_t count,
52                                 unsigned char *c),
53                                 void *ctx,
54                                 struct openpgp_packet_list **packets,
55                                 int maxnum);
56
57 /**
58  *      write_openpgp_stream - Reads a stream of OpenPGP packets.
59  *      @putchar_func: The function to put the next character to the stream.
60  *      @ctx: A pointer to the context structure for putchar_func.
61  *      @packets: The list of packets.
62  *
63  *      This function uses putchar_func to write characters to an OpenPGP
64  *      packet stream from a linked list of packets.
65  */
66 int write_openpgp_stream(int (*putchar_func)(void *ctx, size_t count,
67                                                 unsigned char *c),
68                                 void *ctx,
69                                 struct openpgp_packet_list *packets);
70
71 /**
72  *      flatten_publickey - Convert a publickey to an OpenPGP packet list.
73  *      @key: The public key.
74  *      @packets: The outputted packet list.
75  *      @list_end: The end of the packet list.
76  *
77  *      This function converts public key structure to a linked list of OpenPGP
78  *      packets ready for outputing or storage. If we're not appending to an
79  *      existing list then both packets & list_end will be pointers to NULLs,
80  *      other wise packets should point to the start of the list and list_end
81  *      to the end so we can append to the end.
82  */
83 int flatten_publickey(struct openpgp_publickey *key,
84                         struct openpgp_packet_list **packets,
85                         struct openpgp_packet_list **list_end);
86
87 #endif /* __PARSEKEY_H__ */