src: for every AGPL3.0 file, add SPDX identifier.
[oweals/gnunet.git] / src / include / gnunet_testbed_logger_service.h
1 /*
2       This file is part of GNUnet
3       Copyright (C) 2008--2013 GNUnet e.V.
4
5       GNUnet is free software: you can redistribute it and/or modify it
6       under the terms of the GNU Affero General Public License as published
7       by the Free Software Foundation, either version 3 of the License,
8       or (at your 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       Affero General Public License for more details.
14      
15       You should have received a copy of the GNU Affero General Public License
16       along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18      SPDX-License-Identifier: AGPL3.0-or-later
19  */
20
21 /**
22  * @author Sree Harsha Totakura <sreeharsha@totakura.in>
23  *
24  * @file
25  * API for submitting data to the testbed logger service
26  *
27  * @defgroup testbed-logger  Testbed Logger service
28  * Submit data to the testbed logger service.
29  * @{
30  */
31
32 #ifndef GNUNET_TESTBED_LOGGER_SERVICE_H
33 #define GNUNET_TESTBED_LOGGER_SERVICE_H
34
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #if 0                           /* keep Emacsens' auto-indent happy */
39 }
40 #endif
41 #endif
42
43 #include "gnunet_util_lib.h"
44
45 /**
46  * Opaque handle for the logging service
47  */
48 struct GNUNET_TESTBED_LOGGER_Handle;
49
50
51 /**
52  * Connect to the testbed logger service
53  *
54  * @param cfg configuration to use
55  * @return the handle which can be used for sending data to the service; NULL
56  *           upon any error
57  */
58 struct GNUNET_TESTBED_LOGGER_Handle *
59 GNUNET_TESTBED_LOGGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
60
61
62 /**
63  * Disconnect from the logger service.  Also cancels any pending send handles.
64  *
65  * @param h the logger handle
66  */
67 void
68 GNUNET_TESTBED_LOGGER_disconnect (struct GNUNET_TESTBED_LOGGER_Handle *h);
69
70
71 /**
72  * Functions of this type are called to notify a successful transmission of the
73  * message to the logger service.
74  *
75  * @param cls the closure given to GNUNET_TESTBED_LOGGER_send()
76  * @param size the amount of data sent
77  */
78 typedef void
79 (*GNUNET_TESTBED_LOGGER_FlushCompletion) (void *cls,
80                                           size_t size);
81
82
83 /**
84  * Send data to be logged to the logger service.  The data will be buffered and
85  * will be sent upon an explicit call to GNUNET_TESTBED_LOGGER_flush() or upon
86  * exceeding a threshold size.
87  *
88  * @param h the logger handle
89  * @param data the data to send;
90  * @param size how many bytes of @a data to send
91  */
92 void
93 GNUNET_TESTBED_LOGGER_write (struct GNUNET_TESTBED_LOGGER_Handle *h,
94                              const void *data,
95                              size_t size);
96
97
98 /**
99  * Flush the buffered data to the logger service
100  *
101  * @param h the logger handle
102  * @param cb the callback to call after the data is flushed
103  * @param cb_cls the closure for @a cb
104  */
105 void
106 GNUNET_TESTBED_LOGGER_flush (struct GNUNET_TESTBED_LOGGER_Handle *h,
107                              GNUNET_TESTBED_LOGGER_FlushCompletion cb,
108                              void *cb_cls);
109
110
111 /**
112  * Cancel notification upon flush.  Should only be used when the flush
113  * completion callback given to GNUNET_TESTBED_LOGGER_flush() is not already
114  * called.
115  *
116  * @param h the logger handle
117  */
118 void
119 GNUNET_TESTBED_LOGGER_flush_cancel (struct GNUNET_TESTBED_LOGGER_Handle *h);
120
121
122 #if 0                           /* keep Emacsens' auto-indent happy */
123 {
124 #endif
125 #ifdef __cplusplus
126 }
127 #endif
128
129 #endif  /* GNUNET_TESTBED_LOGGER_SERVICE_H */
130
131 /** @} */  /* end of group */
132
133 /* End of gnunet_testbed_logger_service.h */