From fa4a01e4a27dd4b3a57077acbd0e69f95d55944a Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sat, 16 Jul 2011 22:38:50 +0200 Subject: [PATCH] Use const pointer to source in base64 and hex routines. --- src/utils.c | 8 ++++---- src/utils.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/utils.c b/src/utils.c index ab426ab..022ac25 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 648a607..67c94f3 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); -- 2.25.1