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