diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-03-04 14:09:57 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-03-04 14:09:57 +0000 |
commit | 87534f72154e9bc859919afaebbc7321dc4fda87 (patch) | |
tree | 4dbc81d20e9ec45992e724133e1dd772b281fb9e /src/include/gnunet_strings_lib.h | |
parent | fc646798891d075673e2ad8f2011c1e15160b6c1 (diff) | |
download | gnunet-87534f72154e9bc859919afaebbc7321dc4fda87.tar.gz gnunet-87534f72154e9bc859919afaebbc7321dc4fda87.zip |
-renaming
Diffstat (limited to 'src/include/gnunet_strings_lib.h')
-rw-r--r-- | src/include/gnunet_strings_lib.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h index 8101a8113..4fb007707 100644 --- a/src/include/gnunet_strings_lib.h +++ b/src/include/gnunet_strings_lib.h | |||
@@ -213,6 +213,42 @@ GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta); | |||
213 | const char * | 213 | const char * |
214 | GNUNET_STRINGS_get_short_name (const char *filename); | 214 | GNUNET_STRINGS_get_short_name (const char *filename); |
215 | 215 | ||
216 | |||
217 | /** | ||
218 | * Convert binary data to ASCII encoding. The ASCII encoding is rather | ||
219 | * GNUnet specific. It was chosen such that it only uses characters | ||
220 | * in [0-9A-V], can be produced without complex arithmetics and uses a | ||
221 | * small number of characters. The GNUnet encoding uses 103 characters. | ||
222 | * Does not append 0-terminator, but returns a pointer to the place where | ||
223 | * it should be placed, if needed. | ||
224 | * | ||
225 | * @param data data to encode | ||
226 | * @param size size of data (in bytes) | ||
227 | * @param out buffer to fill | ||
228 | * @param out_size size of the buffer. Must be large enough to hold | ||
229 | * ((size*8) + (((size*8) % 5) > 0 ? 5 - ((size*8) % 5) : 0)) / 5 | ||
230 | * @return pointer to the next byte in 'out' or NULL on error. | ||
231 | */ | ||
232 | char * | ||
233 | GNUNET_STRINGS_data_to_string (unsigned char *data, size_t size, | ||
234 | char *out, size_t out_size); | ||
235 | |||
236 | |||
237 | /** | ||
238 | * Convert ASCII encoding back to data | ||
239 | * out_size must match exactly the size of the data before it was encoded. | ||
240 | * | ||
241 | * @param enc the encoding | ||
242 | * @param enclen number of characters in 'enc' (without 0-terminator, which can be missing) | ||
243 | * @param out location where to store the decoded data | ||
244 | * @param out_size sizeof the output buffer | ||
245 | * @return GNUNET_OK on success, GNUNET_SYSERR if result has the wrong encoding | ||
246 | */ | ||
247 | int | ||
248 | GNUNET_STRINGS_string_to_data (const char *enc, size_t enclen, | ||
249 | unsigned char *out, size_t out_size); | ||
250 | |||
251 | |||
216 | #if 0 /* keep Emacsens' auto-indent happy */ | 252 | #if 0 /* keep Emacsens' auto-indent happy */ |
217 | { | 253 | { |
218 | #endif | 254 | #endif |