-simplify logic
[oweals/gnunet.git] / src / include / gnunet_rps_service.h
1 /*
2       This file is part of GNUnet
3       (C) 
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_rps_service.h
23  * @brief API to the rps service
24  * @author Julius Bünger
25  */
26 #ifndef GNUNET_RPS_SERVICE_H
27 #define GNUNET_RPS_SERVICE_H
28
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #if 0                           /* keep Emacsens' auto-indent happy */
33 }
34 #endif
35 #endif
36
37 /**
38  * Version of the rps API.
39  */
40 #define GNUNET_RPS_VERSION 0x00000000
41
42 typedef void (* GNUNET_RPS_NotifyReadyCB) (void *cls, uint64_t num_peers, struct GNUNET_PeerIdentity *peers);
43
44 /**
45  * Request n random peers.
46  *
47  * This is a wrapper function that makes it useless to have to
48  * (dis)connect from/to the service.
49  */
50   struct GNUNET_RPS_Request_Handle *
51 GNUNET_RPS_request_peers_single_call (const struct GNUNET_CONFIGURATION_Handle *cfg,
52                           uint64_t n,
53                           GNUNET_RPS_NotifyReadyCB ready_cb,
54                           void *cls);
55
56 /**
57  * Connect to the rps service
58  */
59   struct GNUNET_RPS_Handle *
60 GNUNET_RPS_connect( const struct GNUNET_CONFIGURATION_Handle *cfg );
61
62 /**
63  * Request n random peers.
64  *
65  * This does exacly the same as GNUNET_RPS_request_peers_single_call
66  * but needs a GNUNET_RPS_Handle.
67  * This exists only for other parts of GNUnet that expect having to
68  * (dis)connect from/to a service.
69  */
70   struct GNUNET_RPS_Request_Handle *
71 GNUNET_RPS_request_peers (struct GNUNET_RPS_Handle *h, uint64_t n,
72                           GNUNET_RPS_NotifyReadyCB ready_cb,
73                           void *cls);
74
75 /**
76  * Cancle an issued request.
77  */
78   void
79 GNUNET_RPS_request_cancel ( struct GNUNET_RPS_Request_Handle *rh );
80
81 /**
82  * Disconnect from the rps service
83  */
84   void
85 GNUNET_RPS_disconnect ( struct GNUNET_RPS_Handle *h );
86
87 #if 0                           /* keep Emacsens' auto-indent happy */
88 {
89 #endif
90 #ifdef __cplusplus
91 }
92 #endif
93
94 #endif