gnunet_reclaim_attribute_plugin.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 Martin Schanzenbach
  18. *
  19. * @file
  20. * Plugin API for reclaim attribute types
  21. *
  22. * @defgroup reclaim-attribute-plugin reclaim plugin API for attributes/claims
  23. * @{
  24. */
  25. #ifndef GNUNET_RECLAIM_ATTRIBUTE_PLUGIN_H
  26. #define GNUNET_RECLAIM_ATTRIBUTE_PLUGIN_H
  27. #include "gnunet_util_lib.h"
  28. #include "gnunet_reclaim_attribute_lib.h"
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #if 0 /* keep Emacsens' auto-indent happy */
  32. }
  33. #endif
  34. #endif
  35. /**
  36. * Function called to convert the binary value @a data of an attribute of
  37. * type @a type to a human-readable string.
  38. *
  39. * @param cls closure
  40. * @param type type of the attribute
  41. * @param data value in binary encoding
  42. * @param data_size number of bytes in @a data
  43. * @return NULL on error, otherwise human-readable representation of the value
  44. */
  45. typedef char *(*GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction) (
  46. void *cls,
  47. uint32_t type,
  48. const void *data,
  49. size_t data_size);
  50. /**
  51. * Function called to convert human-readable version of the value @a s
  52. * of an attribute of type @a type to the respective binary
  53. * representation.
  54. *
  55. * @param cls closure
  56. * @param type type of the attribute
  57. * @param s human-readable string
  58. * @param data set to value in binary encoding (will be allocated)
  59. * @param data_size set to number of bytes in @a data
  60. * @return #GNUNET_OK on success
  61. */
  62. typedef int (*GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction) (
  63. void *cls,
  64. uint32_t type,
  65. const char *s,
  66. void **data,
  67. size_t *data_size);
  68. /**
  69. * Function called to convert a type name to the
  70. * corresponding number.
  71. *
  72. * @param cls closure
  73. * @param typename name to convert
  74. * @return corresponding number, UINT32_MAX on error
  75. */
  76. typedef uint32_t (*GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction) (
  77. void *cls,
  78. const char *typename);
  79. /**
  80. * Function called to convert a type number (i.e. 1) to the
  81. * corresponding type string
  82. *
  83. * @param cls closure
  84. * @param type number of a type to convert
  85. * @return corresponding typestring, NULL on error
  86. */
  87. typedef const char *(*GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction) (
  88. void *cls,
  89. uint32_t type);
  90. /**
  91. * Each plugin is required to return a pointer to a struct of this
  92. * type as the return value from its entry point.
  93. */
  94. struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions
  95. {
  96. /**
  97. * Closure for all of the callbacks.
  98. */
  99. void *cls;
  100. /**
  101. * Conversion to string.
  102. */
  103. GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction value_to_string;
  104. /**
  105. * Conversion to binary.
  106. */
  107. GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction string_to_value;
  108. /**
  109. * Typename to number.
  110. */
  111. GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction typename_to_number;
  112. /**
  113. * Number to typename.
  114. */
  115. GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction number_to_typename;
  116. };
  117. #if 0 /* keep Emacsens' auto-indent happy */
  118. {
  119. #endif
  120. #ifdef __cplusplus
  121. }
  122. #endif
  123. #endif
  124. /** @} */ /* end of group */