revert
[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
19 /**
20  * @author Sree Harsha Totakura <sreeharsha@totakura.in>
21  *
22  * @file
23  * API for submitting data to the testbed logger service
24  *
25  * @defgroup testbed-logger  Testbed Logger service
26  * Submit data to the testbed logger service.
27  * @{
28  */
29
30 #ifndef GNUNET_TESTBED_LOGGER_SERVICE_H
31 #define GNUNET_TESTBED_LOGGER_SERVICE_H
32
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #if 0                           /* keep Emacsens' auto-indent happy */
37 }
38 #endif
39 #endif
40
41 #include "gnunet_util_lib.h"
42
43 /**
44  * Opaque handle for the logging service
45  */
46 struct GNUNET_TESTBED_LOGGER_Handle;
47
48
49 /**
50  * Connect to the testbed logger service
51  *
52  * @param cfg configuration to use
53  * @return the handle which can be used for sending data to the service; NULL
54  *           upon any error
55  */
56 struct GNUNET_TESTBED_LOGGER_Handle *
57 GNUNET_TESTBED_LOGGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
58
59
60 /**
61  * Disconnect from the logger service.  Also cancels any pending send handles.
62  *
63  * @param h the logger handle
64  */
65 void
66 GNUNET_TESTBED_LOGGER_disconnect (struct GNUNET_TESTBED_LOGGER_Handle *h);
67
68
69 /**
70  * Functions of this type are called to notify a successful transmission of the
71  * message to the logger service.
72  *
73  * @param cls the closure given to GNUNET_TESTBED_LOGGER_send()
74  * @param size the amount of data sent
75  */
76 typedef void
77 (*GNUNET_TESTBED_LOGGER_FlushCompletion) (void *cls,
78                                           size_t size);
79
80
81 /**
82  * Send data to be logged to the logger service.  The data will be buffered and
83  * will be sent upon an explicit call to GNUNET_TESTBED_LOGGER_flush() or upon
84  * exceeding a threshold size.
85  *
86  * @param h the logger handle
87  * @param data the data to send;
88  * @param size how many bytes of @a data to send
89  */
90 void
91 GNUNET_TESTBED_LOGGER_write (struct GNUNET_TESTBED_LOGGER_Handle *h,
92                              const void *data,
93                              size_t size);
94
95
96 /**
97  * Flush the buffered data to the logger service
98  *
99  * @param h the logger handle
100  * @param cb the callback to call after the data is flushed
101  * @param cb_cls the closure for @a cb
102  */
103 void
104 GNUNET_TESTBED_LOGGER_flush (struct GNUNET_TESTBED_LOGGER_Handle *h,
105                              GNUNET_TESTBED_LOGGER_FlushCompletion cb,
106                              void *cb_cls);
107
108
109 /**
110  * Cancel notification upon flush.  Should only be used when the flush
111  * completion callback given to GNUNET_TESTBED_LOGGER_flush() is not already
112  * called.
113  *
114  * @param h the logger handle
115  */
116 void
117 GNUNET_TESTBED_LOGGER_flush_cancel (struct GNUNET_TESTBED_LOGGER_Handle *h);
118
119
120 #if 0                           /* keep Emacsens' auto-indent happy */
121 {
122 #endif
123 #ifdef __cplusplus
124 }
125 #endif
126
127 #endif  /* GNUNET_TESTBED_LOGGER_SERVICE_H */
128
129 /** @} */  /* end of group */
130
131 /* End of gnunet_testbed_logger_service.h */