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
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @author Christian Grothoff
25 * Plugin API for GNS record types
27 * @defgroup gnsrecord-plugin GNS Record plugin API
28 * To be implemented by applications defining new record types.
30 * @see [Documentation](https://gnunet.org/gns-plugins)
34 #ifndef GNUNET_GNSRECORD_PLUGIN_H
35 #define GNUNET_GNSRECORD_PLUGIN_H
40 #if 0 /* keep Emacsens' auto-indent happy */
47 * Function called to convert the binary value @a data of a record of
48 * type @a type to a human-readable string.
51 * @param type type of the record
52 * @param data value in binary encoding
53 * @param data_size number of bytes in @a data
54 * @return NULL on error, otherwise human-readable representation of the value
56 typedef char * (*GNUNET_GNSRECORD_ValueToStringFunction) (void *cls,
63 * Function called to convert human-readable version of the value @a s
64 * of a record of type @a type to the respective binary
68 * @param type type of the record
69 * @param s human-readable string
70 * @param data set to value in binary encoding (will be allocated)
71 * @param data_size set to number of bytes in @a data
72 * @return #GNUNET_OK on success
74 typedef int (*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
89 typedef uint32_t (*GNUNET_GNSRECORD_TypenameToNumberFunction) (void *cls,
90 const char *dns_typename);
94 * Function called to convert a type number (i.e. 1) to the
95 * corresponding type string (i.e. "A")
98 * @param type number of a type to convert
99 * @return corresponding typestring, NULL on error
101 typedef const char * (*GNUNET_GNSRECORD_NumberToTypenameFunction) (void *cls,
106 * Each plugin is required to return a pointer to a struct of this
107 * type as the return value from its entry point.
109 struct GNUNET_GNSRECORD_PluginFunctions
113 * Closure for all of the callbacks.
118 * Conversion to string.
120 GNUNET_GNSRECORD_ValueToStringFunction value_to_string;
123 * Conversion to binary.
125 GNUNET_GNSRECORD_StringToValueFunction string_to_value;
128 * Typename to number.
130 GNUNET_GNSRECORD_TypenameToNumberFunction typename_to_number;
133 * Number to typename.
135 GNUNET_GNSRECORD_NumberToTypenameFunction number_to_typename;
139 /** @} */ /* end of group */
141 #if 0 /* keep Emacsens' auto-indent happy */