Commit aa6c48fa authored by Pekka Pessi's avatar Pekka Pessi

ipt: using isize_t, usize_t, issize_t in API.

Internally using size_t.

darcs-hash:20060906191926-65a35-c53873aad548c35a36bd3ca8490b24c843de9636.gz
parent 9f2c3bc5
......@@ -74,13 +74,14 @@ static unsigned char const code[] =
* }
* @endcode
*/
int base64_d(char buf[], int bsiz, char const *b64s)
isize_t base64_d(char buf[], isize_t bsiz, char const *b64s)
{
static unsigned char decode[256] = "";
unsigned char const *s = (unsigned char const *)b64s;
unsigned char c, b1, b2 = B64EOF, b3 = B64EOF, b4 = B64EOF;
unsigned long w;
int i, len = 0, total_len = 0;
isize_t i, len = 0, total_len = 0;
if (b64s == NULL)
return 0;
......@@ -186,13 +187,14 @@ int base64_d(char buf[], int bsiz, char const *b64s)
* N. Freed, N. Borenstein, November 1996.
*
*/
int base64_e(char buf[], int bsiz, void *data, int dsiz)
isize_t base64_e(char buf[], isize_t bsiz, void *data, isize_t dsiz)
{
unsigned char *s = (unsigned char *)buf;
unsigned char *b = (unsigned char *)data;
unsigned long w;
size_t i, n, slack = (unsigned)dsiz % 3;
size_t dsize = (size_t)dsiz - slack, bsize = (size_t)bsiz;
isize_t i, n, slack = (unsigned)dsiz % 3;
isize_t dsize = dsiz - slack, bsize = bsiz;
if (bsize == 0)
s = NULL;
......
......@@ -31,7 +31,7 @@
#include "sofia-sip/rc4.h"
void rc4_init(const void *vseed, int seed_len, rc4_t *state) {
void rc4_init(const void *vseed, isize_t seed_len, rc4_t *state) {
short i; rc4_u8 j; rc4_u8 k;
const rc4_u8 *seed = (const rc4_u8 *)vseed;
......@@ -45,7 +45,7 @@ void rc4_init(const void *vseed, int seed_len, rc4_t *state) {
for (i = 0, j = 0, k = 0;
i < 256;
i++, k++, k >= (unsigned)seed_len ? k = 0 : 0) {
i++, k++, k >= seed_len ? k = 0 : 0) {
rc4_u8 a = array[i];
rc4_u8 b = array[j += a + seed[k]];
......@@ -54,7 +54,7 @@ void rc4_init(const void *vseed, int seed_len, rc4_t *state) {
}
}
void rc4(void *buffer, int len, rc4_t *state) {
void rc4(void *buffer, isize_t len, rc4_t *state) {
rc4_u8 *buf = (rc4_u8 *)buffer;
rc4_u8 *array = state->rc4_array;
rc4_u8 i = state->rc4_i;
......
......@@ -43,14 +43,16 @@
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
*/
#include <sofia-sip/su_config.h>
#ifndef SU_TYPES_H
#include <sofia-sip/su_types.h>
#endif
SOFIA_BEGIN_DECLS
/** Decode a BASE64-encoded string. */
SOFIAPUBFUN int base64_d(char buf[], int bsiz, char const *b64s);
SOFIAPUBFUN isize_t base64_d(char buf[], isize_t bsiz, char const *b64s);
/** Encode data with BASE64. */
SOFIAPUBFUN int base64_e(char buf[], int bsiz, void *data, int dsiz);
SOFIAPUBFUN isize_t base64_e(char buf[], isize_t bsiz, void *data, isize_t dsiz);
/** Calculate size of n bytes encoded in base64 */
#define BASE64_SIZE(n) ((((n) + 2) / 3) * 4)
......
......@@ -57,10 +57,10 @@ typedef struct {
} rc4_t;
/** Key RC4 context. */
SOFIAPUBFUN void rc4_init(const void *seed, int seed_len, rc4_t *state);
SOFIAPUBFUN void rc4_init(const void *seed, isize_t seed_len, rc4_t *state);
/** Generate RC4 stream. */
SOFIAPUBFUN void rc4(void *buffer, int len, rc4_t *state);
SOFIAPUBFUN void rc4(void *buffer, isize_t len, rc4_t *state);
#if defined(__cplusplus)
}
......
......@@ -35,11 +35,14 @@
*
*/
#include <sofia-sip/su_config.h>
#ifndef SU_TYPES_H
#include <sofia-sip/su_types.h>
#endif
SOFIA_BEGIN_DECLS
SOFIAPUBFUN int token64_e(char b[], int bsiz, void const *data, int dlen);
SOFIAPUBFUN isize_t token64_e(char b[], isize_t bsiz,
void const *data, isize_t dlen);
/** Calculate size of n bytes encoded in token-64 */
#define TOKEN64_SIZE(n) (((n + 2) / 3) * 4)
......
......@@ -47,9 +47,9 @@ static const char code[64] =
* A token is case-independent, so this is really not a good idea.
* Use msg_random_token() instead.
*/
int token64_e(char b[], int bsiz, void const *data, int dlen)
isize_t token64_e(char b[], isize_t bsiz, void const *data, isize_t dlen)
{
int i, n, slack;
size_t i, n, slack;
unsigned char const *h = data;
char *s = b, *end = b + bsiz;
long w;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment