diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-07 18:08:05 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-07 18:08:05 +0000 |
commit | 91dfeebc1a2e840f88904aab7f43ce214c3eb03a (patch) | |
tree | 36ac52a744e89799ea51f1d572b7cf7302f6ba8d /src/include | |
parent | 2866a3a85ea457f29f4746ccae57af369746c5fa (diff) | |
download | gnunet-91dfeebc1a2e840f88904aab7f43ce214c3eb03a.tar.gz gnunet-91dfeebc1a2e840f88904aab7f43ce214c3eb03a.zip |
-moving friends file parsing logic into its own library
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/Makefile.am | 5 | ||||
-rw-r--r-- | src/include/gnunet_friends_lib.h | 95 |
2 files changed, 98 insertions, 2 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 634ce6f23..8a848135b 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -3,7 +3,7 @@ SUBDIRS = . | |||
3 | gnunetincludedir = $(includedir)/gnunet | 3 | gnunetincludedir = $(includedir)/gnunet |
4 | 4 | ||
5 | nodist_gnunetinclude_HEADERS = \ | 5 | nodist_gnunetinclude_HEADERS = \ |
6 | gnunet_directories.h | 6 | gnunet_directories.h |
7 | 7 | ||
8 | if MINGW | 8 | if MINGW |
9 | WINPROC = winproc.h | 9 | WINPROC = winproc.h |
@@ -44,6 +44,7 @@ gnunetinclude_HEADERS = \ | |||
44 | gnunet_dns_service.h \ | 44 | gnunet_dns_service.h \ |
45 | gnunet_dv_service.h \ | 45 | gnunet_dv_service.h \ |
46 | gnunet_fragmentation_lib.h \ | 46 | gnunet_fragmentation_lib.h \ |
47 | gnunet_friends_lib.h \ | ||
47 | gnunet_fs_service.h \ | 48 | gnunet_fs_service.h \ |
48 | gnunet_getopt_lib.h \ | 49 | gnunet_getopt_lib.h \ |
49 | gnunet_gns_service.h \ | 50 | gnunet_gns_service.h \ |
@@ -87,4 +88,4 @@ gnunetinclude_HEADERS = \ | |||
87 | gnunet_transport_plugin.h \ | 88 | gnunet_transport_plugin.h \ |
88 | gnunet_tun_lib.h \ | 89 | gnunet_tun_lib.h \ |
89 | gnunet_util_lib.h \ | 90 | gnunet_util_lib.h \ |
90 | gnunet_vpn_service.h | 91 | gnunet_vpn_service.h |
diff --git a/src/include/gnunet_friends_lib.h b/src/include/gnunet_friends_lib.h new file mode 100644 index 000000000..dda1d3245 --- /dev/null +++ b/src/include/gnunet_friends_lib.h | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (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 | #include "gnunet_util_lib.h" | ||
30 | |||
31 | |||
32 | /** | ||
33 | * Signature of a function called on each friend found. | ||
34 | * | ||
35 | * @param cls closure | ||
36 | * @param friend peer identity of the friend | ||
37 | */ | ||
38 | typedef void (*GNUNET_FRIENDS_Callback)(void *cls, | ||
39 | const struct GNUNET_PeerIdentity *friend); | ||
40 | |||
41 | |||
42 | /** | ||
43 | * Parse the FRIENDS file. | ||
44 | * | ||
45 | * @param cfg our configuration | ||
46 | * @param cb function to call on each friend found | ||
47 | * @param cb_cls closure for @a cb | ||
48 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on parsing errors | ||
49 | */ | ||
50 | int | ||
51 | GNUNET_FRIENDS_parse (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
52 | GNUNET_FRIENDS_Callback cb, | ||
53 | void *cb_cls); | ||
54 | |||
55 | |||
56 | /** | ||
57 | * Handle for writing a friends file. | ||
58 | */ | ||
59 | struct GNUNET_FRIENDS_Writer; | ||
60 | |||
61 | |||
62 | /** | ||
63 | * Start writing a fresh FRIENDS file. Will make a backup of the | ||
64 | * old one. | ||
65 | * | ||
66 | * @param cfg configuration to use. | ||
67 | * @return NULL on error | ||
68 | */ | ||
69 | struct GNUNET_FRIENDS_Writer * | ||
70 | GNUNET_FRIENDS_write_start (const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
71 | |||
72 | |||
73 | /** | ||
74 | * Finish writing out the friends file. | ||
75 | * | ||
76 | * @param w write handle | ||
77 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
78 | */ | ||
79 | int | ||
80 | GNUNET_FRIENDS_write_stop (struct GNUNET_FRIENDS_Writer *w); | ||
81 | |||
82 | |||
83 | /** | ||
84 | * Add a friend to the friends file. | ||
85 | * | ||
86 | * @param w write handle | ||
87 | * @param friend friend to add | ||
88 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | ||
89 | */ | ||
90 | int | ||
91 | GNUNET_FRIENDS_write (struct GNUNET_FRIENDS_Writer *w, | ||
92 | const struct GNUNET_PeerIdentity *friend); | ||
93 | |||
94 | |||
95 | #endif | ||