diff options
Diffstat (limited to 'src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c')
-rw-r--r-- | src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c | 60 |
1 files changed, 28 insertions, 32 deletions
diff --git a/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c b/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c index 4d506fe67..bd0bb1741 100644 --- a/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c +++ b/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -20,8 +20,9 @@ | |||
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file reclaim-attribute/plugin_reclaim_attribute_gnuid.c | 22 | * @file reclaim-attribute/plugin_reclaim_attribute_gnuid.c |
23 | * @brief identity attribute plugin to provide the API for fundamental | 23 | * @brief reclaim-attribute-plugin-gnuid attribute plugin to provide the API for |
24 | * attribute types. | 24 | * fundamental |
25 | * attribute types. | ||
25 | * | 26 | * |
26 | * @author Martin Schanzenbach | 27 | * @author Martin Schanzenbach |
27 | */ | 28 | */ |
@@ -42,9 +43,9 @@ | |||
42 | */ | 43 | */ |
43 | static char * | 44 | static char * |
44 | gnuid_value_to_string (void *cls, | 45 | gnuid_value_to_string (void *cls, |
45 | uint32_t type, | 46 | uint32_t type, |
46 | const void *data, | 47 | const void *data, |
47 | size_t data_size) | 48 | size_t data_size) |
48 | { | 49 | { |
49 | 50 | ||
50 | switch (type) | 51 | switch (type) |
@@ -70,22 +71,22 @@ gnuid_value_to_string (void *cls, | |||
70 | */ | 71 | */ |
71 | static int | 72 | static int |
72 | gnuid_string_to_value (void *cls, | 73 | gnuid_string_to_value (void *cls, |
73 | uint32_t type, | 74 | uint32_t type, |
74 | const char *s, | 75 | const char *s, |
75 | void **data, | 76 | void **data, |
76 | size_t *data_size) | 77 | size_t *data_size) |
77 | { | 78 | { |
78 | if (NULL == s) | 79 | if (NULL == s) |
79 | return GNUNET_SYSERR; | 80 | return GNUNET_SYSERR; |
80 | switch (type) | 81 | switch (type) |
81 | { | 82 | { |
82 | 83 | ||
83 | case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING: | 84 | case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING: |
84 | *data = GNUNET_strdup (s); | 85 | *data = GNUNET_strdup (s); |
85 | *data_size = strlen (s); | 86 | *data_size = strlen (s); |
86 | return GNUNET_OK; | 87 | return GNUNET_OK; |
87 | default: | 88 | default: |
88 | return GNUNET_SYSERR; | 89 | return GNUNET_SYSERR; |
89 | } | 90 | } |
90 | } | 91 | } |
91 | 92 | ||
@@ -94,13 +95,12 @@ gnuid_string_to_value (void *cls, | |||
94 | * Mapping of attribute type numbers to human-readable | 95 | * Mapping of attribute type numbers to human-readable |
95 | * attribute type names. | 96 | * attribute type names. |
96 | */ | 97 | */ |
97 | static struct { | 98 | static struct |
99 | { | ||
98 | const char *name; | 100 | const char *name; |
99 | uint32_t number; | 101 | uint32_t number; |
100 | } gnuid_name_map[] = { | 102 | } gnuid_name_map[] = {{"STRING", GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING}, |
101 | { "STRING", GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING }, | 103 | {NULL, UINT32_MAX}}; |
102 | { NULL, UINT32_MAX } | ||
103 | }; | ||
104 | 104 | ||
105 | 105 | ||
106 | /** | 106 | /** |
@@ -111,15 +111,13 @@ static struct { | |||
111 | * @return corresponding number, UINT32_MAX on error | 111 | * @return corresponding number, UINT32_MAX on error |
112 | */ | 112 | */ |
113 | static uint32_t | 113 | static uint32_t |
114 | gnuid_typename_to_number (void *cls, | 114 | gnuid_typename_to_number (void *cls, const char *gnuid_typename) |
115 | const char *gnuid_typename) | ||
116 | { | 115 | { |
117 | unsigned int i; | 116 | unsigned int i; |
118 | 117 | ||
119 | i=0; | 118 | i = 0; |
120 | while ( (NULL != gnuid_name_map[i].name) && | 119 | while ((NULL != gnuid_name_map[i].name) && |
121 | (0 != strcasecmp (gnuid_typename, | 120 | (0 != strcasecmp (gnuid_typename, gnuid_name_map[i].name))) |
122 | gnuid_name_map[i].name)) ) | ||
123 | i++; | 121 | i++; |
124 | return gnuid_name_map[i].number; | 122 | return gnuid_name_map[i].number; |
125 | } | 123 | } |
@@ -133,14 +131,12 @@ gnuid_typename_to_number (void *cls, | |||
133 | * @return corresponding typestring, NULL on error | 131 | * @return corresponding typestring, NULL on error |
134 | */ | 132 | */ |
135 | static const char * | 133 | static const char * |
136 | gnuid_number_to_typename (void *cls, | 134 | gnuid_number_to_typename (void *cls, uint32_t type) |
137 | uint32_t type) | ||
138 | { | 135 | { |
139 | unsigned int i; | 136 | unsigned int i; |
140 | 137 | ||
141 | i=0; | 138 | i = 0; |
142 | while ( (NULL != gnuid_name_map[i].name) && | 139 | while ((NULL != gnuid_name_map[i].name) && (type != gnuid_name_map[i].number)) |
143 | (type != gnuid_name_map[i].number) ) | ||
144 | i++; | 140 | i++; |
145 | return gnuid_name_map[i].name; | 141 | return gnuid_name_map[i].name; |
146 | } | 142 | } |