Clean up file header copyrights
[onak.git] / merge.h
1 /*
2  * merge.h - Routines to merge OpenPGP public keys.
3  *
4  * Copyright 2002-2005,2007,2011 Jonathan McDowell <noodles@earth.li>
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the Free
8  * Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc., 51
17  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 #ifndef __MERGE_H__
21
22 #include "keystructs.h"
23
24 /**
25  *      compare_packets - Check to see if 2 OpenPGP packets are the same.
26  *      @a: The first packet to compare.
27  *      @b: The second packet to compare.
28  *
29  *      Takes 2 packets and returns 0 if they are the same, -1 if a is
30  *      less than b, or 1 if a is greater than b.
31  */
32 int compare_packets(struct openpgp_packet *a, struct openpgp_packet *b);
33
34 /**
35  *      merge_keys - Takes 2 public keys and merges them.
36  *      @a: The old key. The merged key is returned in this structure.
37  *      @b: The new key. The changed from old to new keys are returned in this
38  *              structure.
39  *
40  *      This function takes 2 keys and merges them. It then returns the merged
41  *      key in a and the difference between this new key and the original a
42  *      in b (ie newb contains the minimum amount of detail necessary to
43  *      convert olda to newa). The intention is that olda is provided from
44  *      internal storage and oldb from the remote user. newa is then stored in
45  *      internal storage and newb is sent to all our keysync peers.
46  */
47 int merge_keys(struct openpgp_publickey *a, struct openpgp_publickey *b);
48
49 /**
50  *      get_signed_packet - Gets a signed packet from a list.
51  *      @packet_list: The list of packets to look in.
52  *      @packet: The packet to look for.
53  *
54  *      Walks through the signedpacket_list looking for the supplied packet and
55  *      returns it if found. Otherwise returns NULL.
56  */
57 struct openpgp_signedpacket_list *find_signed_packet(
58                 struct openpgp_signedpacket_list *packet_list,
59                 struct openpgp_packet *packet);
60
61 /**
62  *      merge_packet_sigs - Takes 2 signed packets and merges their sigs.
63  *      @old: The old signed packet.
64  *      @new: The new signed packet.
65  *
66  *      Takes 2 signed packet list structures and the sigs of the packets on
67  *      the head of these structures. These packets must both be the same and
68  *      the fully merged structure is returned in old and the minimal
69  *      difference to get from old to new in new.
70  */
71 int merge_packet_sigs(struct openpgp_signedpacket_list *old,
72                         struct openpgp_signedpacket_list *new);
73
74 #endif