Improve to_block4().

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@736 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
Andreas Schneider
2009-05-05 09:00:29 +00:00
parent fc50facaa3
commit cc2df5487a

View File

@@ -170,21 +170,32 @@ error:
i = ptr - alphabet; \
SET_##letter(*block, i); \
} while(0)
/* returns 0 if ok, -1 if not (ie invalid char into the stuff) */
static int to_block4(unsigned long *block, char *source,int num){
/* Returns 0 if ok, -1 if not (ie invalid char into the stuff) */
static int to_block4(unsigned long *block, const char *source, int num) {
char *ptr;
unsigned int i;
*block = 0;
if(num<1)
if (num < 1) {
return 0;
BLOCK(A,0); /* 6 bits */
BLOCK(B,1); /* 12 */
if(num<2)
}
BLOCK(A, 0); /* 6 bit */
BLOCK(B,1); /* 12 bit */
if (num < 2) {
return 0;
BLOCK(C,2); /* 18 */
if(num < 3)
}
BLOCK(C, 2); /* 18 bit */
if (num < 3) {
return 0;
BLOCK(D,3); /* 24 */
}
BLOCK(D, 3); /* 24 bit */
return 0;
}