2 This file is part of GNUnet
3 Copyright (C) 2012, 2013 GNUnet e.V.
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.
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.
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/>.
20 * @author Christian Grothoff
23 * Plugin API for GNS record types
25 * @defgroup gnsrecord-plugin GNS Record plugin API
26 * To be implemented by applications defining new record types.
28 * @see [Documentation](https://gnunet.org/gns-plugins)
32 #ifndef GNUNET_GNSRECORD_PLUGIN_H
33 #define GNUNET_GNSRECORD_PLUGIN_H
38 #if 0 /* keep Emacsens' auto-indent happy */
45 * Function called to convert the binary value @a data of a record of
46 * type @a type to a human-readable string.
49 * @param type type of the record
50 * @param data value in binary encoding
51 * @param data_size number of bytes in @a data
52 * @return NULL on error, otherwise human-readable representation of the value
55 (*GNUNET_GNSRECORD_ValueToStringFunction) (void *cls,
62 * Function called to convert human-readable version of the value @a s
63 * of a record of type @a type to the respective binary
67 * @param type type of the record
68 * @param s human-readable string
69 * @param data set to value in binary encoding (will be allocated)
70 * @param data_size set to number of bytes in @a data
71 * @return #GNUNET_OK on success
74 (*GNUNET_GNSRECORD_StringToValueFunction) (void *cls,
82 * Function called to convert a type name (i.e. "AAAA") to the
83 * corresponding number.
86 * @param dns_typename name to convert
87 * @return corresponding number, UINT32_MAX on error
90 (*GNUNET_GNSRECORD_TypenameToNumberFunction) (void *cls,
91 const char *dns_typename);
95 * Function called to convert a type number (i.e. 1) to the
96 * corresponding type string (i.e. "A")
99 * @param type number of a type to convert
100 * @return corresponding typestring, NULL on error
103 (*GNUNET_GNSRECORD_NumberToTypenameFunction) (void *cls,
108 * Each plugin is required to return a pointer to a struct of this
109 * type as the return value from its entry point.
111 struct GNUNET_GNSRECORD_PluginFunctions
115 * Closure for all of the callbacks.
120 * Conversion to string.
122 GNUNET_GNSRECORD_ValueToStringFunction value_to_string;
125 * Conversion to binary.
127 GNUNET_GNSRECORD_StringToValueFunction string_to_value;
130 * Typename to number.
132 GNUNET_GNSRECORD_TypenameToNumberFunction typename_to_number;
135 * Number to typename.
137 GNUNET_GNSRECORD_NumberToTypenameFunction number_to_typename;
141 /** @} */ /* end of group */
143 #if 0 /* keep Emacsens' auto-indent happy */