From: Guus Sliepen Date: Sat, 16 Jul 2011 20:38:50 +0000 (+0200) Subject: Use const pointer to source in base64 and hex routines. X-Git-Tag: release-1.1pre2~6 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=fa4a01e4a27dd4b3a57077acbd0e69f95d55944a;p=tinc Use const pointer to source in base64 and hex routines. --- diff --git a/src/utils.c b/src/utils.c index ab426ab7..022ac257 100644 --- a/src/utils.c +++ b/src/utils.c @@ -46,14 +46,14 @@ static int charb64decode(char c) { return 63; } -int hex2bin(char *src, char *dst, int length) { +int hex2bin(const char *src, char *dst, int length) { int i; for(i = 0; i < length && src[i * 2] && src[i * 2 + 1]; i++) dst[i] = charhex2bin(src[i * 2]) * 16 + charhex2bin(src[i * 2 + 1]); return i; } -int bin2hex(char *src, char *dst, int length) { +int bin2hex(const char *src, char *dst, int length) { int i; for(i = length - 1; i >= 0; i--) { dst[i * 2 + 1] = hexadecimals[(unsigned char) src[i] & 15]; @@ -63,7 +63,7 @@ int bin2hex(char *src, char *dst, int length) { return length * 2; } -int b64decode(char *src, char *dst, int length) { +int b64decode(const char *src, char *dst, int length) { int i; uint32_t triplet = 0; unsigned char *udst = dst; @@ -90,7 +90,7 @@ int b64decode(char *src, char *dst, int length) { } } -int b64encode(char *src, char *dst, int length) { +int b64encode(const char *src, char *dst, int length) { uint32_t triplet; const unsigned char *usrc = src; int si = length / 3 * 3; diff --git a/src/utils.h b/src/utils.h index 648a6071..67c94f3d 100644 --- a/src/utils.h +++ b/src/utils.h @@ -21,11 +21,11 @@ #ifndef __TINC_UTILS_H__ #define __TINC_UTILS_H__ -extern int hex2bin(char *src, char *dst, int length); -extern int bin2hex(char *src, char *dst, int length); +extern int hex2bin(const char *src, char *dst, int length); +extern int bin2hex(const char *src, char *dst, int length); -extern int b64encode(char *src, char *dst, int length); -extern int b64decode(char *src, char *dst, int length); +extern int b64encode(const char *src, char *dst, int length); +extern int b64decode(const char *src, char *dst, int length); #ifdef HAVE_MINGW extern const char *winerror(int);