* @return pointer to the next byte in 'out' or NULL on error.
*/
char *
-GNUNET_STRINGS_data_to_string (const unsigned char *data, size_t size, char *out, size_t out_size)
+GNUNET_STRINGS_data_to_string (const void *data, size_t size, char *out, size_t out_size)
{
/**
* 32 characters for encoding
unsigned int rpos;
unsigned int bits;
unsigned int vbit;
+ const unsigned char *udata;
GNUNET_assert (data != NULL);
GNUNET_assert (out != NULL);
+ udata = data;
if (out_size < (((size*8) + ((size*8) % 5)) % 5))
{
GNUNET_break (0);
{
if ((rpos < size) && (vbit < 5))
{
- bits = (bits << 8) | data[rpos++]; /* eat 8 more bits */
+ bits = (bits << 8) | udata[rpos++]; /* eat 8 more bits */
vbit += 8;
}
if (vbit < 5)
out[wpos++] = encTable__[(bits >> (vbit - 5)) & 31];
vbit -= 5;
}
- if (wpos != out_size)
- {
- GNUNET_break (0);
- return NULL;
- }
GNUNET_assert (vbit == 0);
return &out[wpos];
}
*/
int
GNUNET_STRINGS_string_to_data (const char *enc, size_t enclen,
- unsigned char *out, size_t out_size)
+ void *out, size_t out_size)
{
unsigned int rpos;
unsigned int wpos;
unsigned int vbit;
int ret;
int shift;
+ unsigned char *uout;
int encoded_len = out_size * 8;
+
+ uout = out;
if (encoded_len % 5 > 0)
{
vbit = encoded_len % 5; /* padding! */
vbit += 5;
if (vbit >= 8)
{
- out[--wpos] = (unsigned char) bits;
+ uout[--wpos] = (unsigned char) bits;
bits >>= 8;
vbit -= 8;
}
}
GNUNET_assert (rpos == 0);
GNUNET_assert (vbit == 0);
+
return GNUNET_OK;
}