change function definitions
Buffers are no longer wired into any input or translation functions. They are supplied as arguments through main.
This commit is contained in:
parent
9b1fe95a8e
commit
848c3749d2
5 changed files with 53 additions and 60 deletions
27
trans.c
27
trans.c
|
@ -7,15 +7,14 @@ unsigned char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
|
|||
"0123456789" \
|
||||
"+/";
|
||||
|
||||
unsigned char *
|
||||
encode(unsigned char *op, int np)
|
||||
int
|
||||
encode(unsigned char *op, int olen, unsigned char *sp)
|
||||
{
|
||||
extern unsigned char s[];
|
||||
unsigned char *sp;
|
||||
int n;
|
||||
unsigned char *sb;
|
||||
|
||||
sp = s;
|
||||
switch (np) {
|
||||
sb = sp;
|
||||
switch (olen) {
|
||||
case 3:
|
||||
*sp++ = b64[(*op & ~3) >> 2];
|
||||
n = (*op++ & 3) << 4;
|
||||
|
@ -39,18 +38,17 @@ encode(unsigned char *op, int np)
|
|||
break;
|
||||
}
|
||||
|
||||
return s;
|
||||
return sp-sb+1;
|
||||
}
|
||||
|
||||
unsigned char *
|
||||
decode(unsigned char *sp, int *np)
|
||||
int
|
||||
decode(unsigned char *sp, int slen, unsigned char *op)
|
||||
{
|
||||
extern unsigned char o[];
|
||||
unsigned char *op;
|
||||
int n, b, atob(int c);
|
||||
unsigned char *ob;
|
||||
|
||||
op = o;
|
||||
switch (*np) {
|
||||
ob = op;
|
||||
switch (slen) {
|
||||
case 4:
|
||||
n = atob(*sp++) << 2;
|
||||
b = atob(*sp++);
|
||||
|
@ -75,9 +73,8 @@ decode(unsigned char *sp, int *np)
|
|||
*op = n + ((atob(*sp) & ~15) >> 4);
|
||||
break;
|
||||
}
|
||||
*np = op-o+1;
|
||||
|
||||
return o;
|
||||
return op-ob+1;
|
||||
}
|
||||
|
||||
int atob(int c)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue