-bringing copyright tags up to FSF standard
[oweals/gnunet.git] / src / include / gnunet_friends_lib.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2013 Christian Grothoff
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file include/gnunet_friends_lib.h
23  * @brief library to read and write the FRIENDS file
24  * @author Christian Grothoff
25  */
26 #ifndef GNUNET_FRIENDS_LIB_H
27 #define GNUNET_FRIENDS_LIB_H
28
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #if 0                           /* keep Emacsens' auto-indent happy */
33 }
34 #endif
35 #endif
36
37 #include "gnunet_util_lib.h"
38
39
40 /**
41  * Signature of a function called on each friend found.
42  *
43  * @param cls closure
44  * @param friend_id peer identity of the friend
45  */
46 typedef void (*GNUNET_FRIENDS_Callback)(void *cls,
47                                         const struct GNUNET_PeerIdentity *friend_id);
48
49
50 /**
51  * Parse the FRIENDS file.
52  *
53  * @param cfg our configuration
54  * @param cb function to call on each friend found
55  * @param cb_cls closure for @a cb
56  * @return #GNUNET_OK on success, #GNUNET_SYSERR on parsing errors
57  */
58 int
59 GNUNET_FRIENDS_parse (const struct GNUNET_CONFIGURATION_Handle *cfg,
60                       GNUNET_FRIENDS_Callback cb,
61                       void *cb_cls);
62
63
64 /**
65  * Handle for writing a friends file.
66  */
67 struct GNUNET_FRIENDS_Writer;
68
69
70 /**
71  * Start writing a fresh FRIENDS file.  Will make a backup of the
72  * old one.
73  *
74  * @param cfg configuration to use.
75  * @return NULL on error
76  */
77 struct GNUNET_FRIENDS_Writer *
78 GNUNET_FRIENDS_write_start (const struct GNUNET_CONFIGURATION_Handle *cfg);
79
80
81 /**
82  * Finish writing out the friends file.
83  *
84  * @param w write handle
85  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
86  */
87 int
88 GNUNET_FRIENDS_write_stop (struct GNUNET_FRIENDS_Writer *w);
89
90
91 /**
92  * Add a friend to the friends file.
93  *
94  * @param w write handle
95  * @param friend_id friend to add
96  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
97  */
98 int
99 GNUNET_FRIENDS_write (struct GNUNET_FRIENDS_Writer *w,
100                       const struct GNUNET_PeerIdentity *friend_id);
101
102
103                                           #if 0                           /* keep Emacsens' auto-indent happy */
104 {
105 #endif
106 #ifdef __cplusplus
107 }
108 #endif
109
110 #endif