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