gnunet_testbed_logger_service.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. This file is part of GNUnet
  3. Copyright (C) 2008--2013 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  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. #ifndef GNUNET_TESTBED_LOGGER_SERVICE_H
  27. #define GNUNET_TESTBED_LOGGER_SERVICE_H
  28. #ifdef __cplusplus
  29. extern "C"
  30. {
  31. #if 0 /* keep Emacsens' auto-indent happy */
  32. }
  33. #endif
  34. #endif
  35. #include "gnunet_util_lib.h"
  36. /**
  37. * Opaque handle for the logging service
  38. */
  39. struct GNUNET_TESTBED_LOGGER_Handle;
  40. /**
  41. * Connect to the testbed logger service
  42. *
  43. * @param cfg configuration to use
  44. * @return the handle which can be used for sending data to the service; NULL
  45. * upon any error
  46. */
  47. struct GNUNET_TESTBED_LOGGER_Handle *
  48. GNUNET_TESTBED_LOGGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
  49. /**
  50. * Disconnect from the logger service. Also cancels any pending send handles.
  51. *
  52. * @param h the logger handle
  53. */
  54. void
  55. GNUNET_TESTBED_LOGGER_disconnect (struct GNUNET_TESTBED_LOGGER_Handle *h);
  56. /**
  57. * Functions of this type are called to notify a successful transmission of the
  58. * message to the logger service.
  59. *
  60. * @param cls the closure given to GNUNET_TESTBED_LOGGER_send()
  61. * @param size the amount of data sent
  62. */
  63. typedef void
  64. (*GNUNET_TESTBED_LOGGER_FlushCompletion) (void *cls,
  65. size_t size);
  66. /**
  67. * Send data to be logged to the logger service. The data will be buffered and
  68. * will be sent upon an explicit call to GNUNET_TESTBED_LOGGER_flush() or upon
  69. * exceeding a threshold size.
  70. *
  71. * @param h the logger handle
  72. * @param data the data to send;
  73. * @param size how many bytes of @a data to send
  74. */
  75. void
  76. GNUNET_TESTBED_LOGGER_write (struct GNUNET_TESTBED_LOGGER_Handle *h,
  77. const void *data,
  78. size_t size);
  79. /**
  80. * Flush the buffered data to the logger service
  81. *
  82. * @param h the logger handle
  83. * @param cb the callback to call after the data is flushed
  84. * @param cb_cls the closure for @a cb
  85. */
  86. void
  87. GNUNET_TESTBED_LOGGER_flush (struct GNUNET_TESTBED_LOGGER_Handle *h,
  88. GNUNET_TESTBED_LOGGER_FlushCompletion cb,
  89. void *cb_cls);
  90. /**
  91. * Cancel notification upon flush. Should only be used when the flush
  92. * completion callback given to GNUNET_TESTBED_LOGGER_flush() is not already
  93. * called.
  94. *
  95. * @param h the logger handle
  96. */
  97. void
  98. GNUNET_TESTBED_LOGGER_flush_cancel (struct GNUNET_TESTBED_LOGGER_Handle *h);
  99. #if 0 /* keep Emacsens' auto-indent happy */
  100. {
  101. #endif
  102. #ifdef __cplusplus
  103. }
  104. #endif
  105. #endif /* GNUNET_TESTBED_LOGGER_SERVICE_H */
  106. /** @} */ /* end of group */
  107. /* End of gnunet_testbed_logger_service.h */