aboutsummaryrefslogtreecommitdiff
path: root/libssh/base64.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2008-11-04 21:59:12 +0000
committerAris Adamantiadis <aris@0xbadc0de.be>2008-11-04 21:59:12 +0000
commit64e73b8d8ab216c5dd8812c8cdad39b7f1bfc4d2 (patch)
tree2c5f71d247607d17b55df210adc6b75d833b3572 /libssh/base64.c
parent90bb81f7b0a729f0508c02586b3d609950d24f2c (diff)
downloadlibssh-64e73b8d8ab216c5dd8812c8cdad39b7f1bfc4d2.tar.gz
libssh-64e73b8d8ab216c5dd8812c8cdad39b7f1bfc4d2.tar.xz
libssh-64e73b8d8ab216c5dd8812c8cdad39b7f1bfc4d2.zip
doxygen fixes. Mostly typos and some comments.
sftp must be fully documented ! git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@187 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/base64.c')
-rw-r--r--libssh/base64.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/libssh/base64.c b/libssh/base64.c
index f16be60..e8d723a 100644
--- a/libssh/base64.c
+++ b/libssh/base64.c
@@ -44,8 +44,12 @@ static int get_equals(char *string);
/* first part : base 64 to binary */
-/* base64_to_bin translates a base64 string into a binary one. important, if something went wrong (ie incorrect char)*/
-/* it returns NULL */
+/** \brief base64_to_bin translates a base64 string into a binary one. important,
+ * \returns NULL if something went wrong (ie incorrect char)
+ * \returns BUFFER containing the decoded string
+ * \internal
+ */
+
BUFFER *base64_to_bin(char *source){
int len;
int equals;
@@ -120,7 +124,7 @@ BUFFER *base64_to_bin(char *source){
}
return NULL;
}
-
+
#define BLOCK(letter,n) do { ptr=strchr(alphabet,source[n]);\
if(!ptr) return -1;\
i=ptr-alphabet;\
@@ -144,7 +148,7 @@ static int to_block4(unsigned long *block, char *source,int num){
return 0;
}
-/* num = numbers of final bytes to be decoded */
+/* num = numbers of final bytes to be decoded */
static int _base64_to_bin(unsigned char dest[3], char *source,int num){
unsigned long block;
if(to_block4(&block,source,num))
@@ -164,7 +168,7 @@ static int get_equals(char *string){
*ptr=0;
ptr++;
}
-
+
return num;
}
@@ -181,18 +185,21 @@ static void _bin_to_base64(unsigned char *dest, unsigned char source[3], int len
case 2:
dest[0]=alphabet[source[0]>>2];
dest[1]=alphabet[(source[1]>>4) | ((source[0] & BITS(2)) << 4)];
- dest[2]=alphabet[(source[1]&BITS(4)) << 2];
+ dest[2]=alphabet[(source[1]&BITS(4)) << 2];
dest[3]='=';
break;
case 3:
- dest[0]=alphabet[(source[0]>>2)];
+ dest[0]=alphabet[(source[0]>>2)];
dest[1]=alphabet[(source[1]>>4) | ((source[0] & BITS(2)) << 4)];
- dest[2]=alphabet[ (source[2] >> 6) | (source[1]&BITS(4)) << 2];
+ dest[2]=alphabet[ (source[2] >> 6) | (source[1]&BITS(4)) << 2];
dest[3]=alphabet[source[2]&BITS(6)];
break;
}
}
-
+/** \brief Converts binary data to a base64 string
+ * \returns the converted string
+ * \internal
+ */
unsigned char *bin_to_base64(unsigned char *source, int len){
int flen=len + (3 - (len %3)); /* round to upper 3 multiple */
unsigned char *buffer;