gnunet_namecache_plugin.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. This file is part of GNUnet
  3. Copyright (C) 2012, 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 Christian Grothoff
  18. *
  19. * @file
  20. * Plugin API for the namecache database backend
  21. *
  22. * @defgroup namecache-plugin Name Cache service plugin API
  23. * Plugin API for the namecache database backend.
  24. *
  25. * @see [Documentation](https://gnunet.org/namecache-plugin-api)
  26. *
  27. * @{
  28. */
  29. #ifndef GNUNET_NAMECACHE_PLUGIN_H
  30. #define GNUNET_NAMECACHE_PLUGIN_H
  31. #include "gnunet_util_lib.h"
  32. #include "gnunet_namecache_service.h"
  33. #include "gnunet_namestore_service.h"
  34. #ifdef __cplusplus
  35. extern "C"
  36. {
  37. #if 0 /* keep Emacsens' auto-indent happy */
  38. }
  39. #endif
  40. #endif
  41. /**
  42. * Function called for matching blocks.
  43. *
  44. * @param cls closure
  45. * @param block lookup result
  46. */
  47. typedef void (*GNUNET_NAMECACHE_BlockCallback) (void *cls,
  48. const struct GNUNET_GNSRECORD_Block *block);
  49. /**
  50. * @brief struct returned by the initialization function of the plugin
  51. */
  52. struct GNUNET_NAMECACHE_PluginFunctions
  53. {
  54. /**
  55. * Closure to pass to all plugin functions.
  56. */
  57. void *cls;
  58. /**
  59. * Cache a block in the datastore. Overwrites existing blocks
  60. * for the same zone and label.
  61. *
  62. * @param cls closure (internal context for the plugin)
  63. * @param block block to cache
  64. * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  65. */
  66. int (*cache_block) (void *cls,
  67. const struct GNUNET_GNSRECORD_Block *block);
  68. /**
  69. * Get the block for a particular zone and label in the
  70. * datastore. Will return at most one result to the iterator.
  71. *
  72. * @param cls closure (internal context for the plugin)
  73. * @param query hash of public key derived from the zone and the label
  74. * @param iter function to call with the result
  75. * @param iter_cls closure for @a iter
  76. * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
  77. */
  78. int (*lookup_block) (void *cls,
  79. const struct GNUNET_HashCode *query,
  80. GNUNET_NAMECACHE_BlockCallback iter, void *iter_cls);
  81. };
  82. #if 0 /* keep Emacsens' auto-indent happy */
  83. {
  84. #endif
  85. #ifdef __cplusplus
  86. }
  87. #endif
  88. #endif
  89. /** @} */ /* end of group */