This commit is contained in:
Daniel Stenberg 2003-01-09 11:31:49 +00:00
Родитель ba25cad6e2
Коммит ed22f75241
1 изменённых файлов: 46 добавлений и 44 удалений

Просмотреть файл

@ -98,7 +98,8 @@ static void base64Decode(unsigned char *dest, char *src, int *rawLength)
} }
decodeQuantum(lastQuantum, src); decodeQuantum(lastQuantum, src);
for(i = 0; i < 3 - equalsTerm; i++) dest[i] = lastQuantum[i]; for(i = 0; i < 3 - equalsTerm; i++)
dest[i] = lastQuantum[i];
} }
@ -198,20 +199,21 @@ int Curl_base64_decode(const char *str, void *data)
#define TEST_NEED_SUCK #define TEST_NEED_SUCK
void *suck(int *); void *suck(int *);
int main(int argc, char **argv, char **envp) { int main(int argc, char **argv, char **envp)
char *base64; {
int base64Len; char *base64;
unsigned char *data; int base64Len;
int dataLen; unsigned char *data;
int dataLen;
data = (unsigned char *)suck(&dataLen); data = (unsigned char *)suck(&dataLen);
base64Len = Curl_base64_encode(data, dataLen, &base64); base64Len = Curl_base64_encode(data, dataLen, &base64);
fprintf(stderr, "%d\n", base64Len); fprintf(stderr, "%d\n", base64Len);
fprintf(stdout, "%s", base64); fprintf(stdout, "%s", base64);
free(base64); free(data); free(base64); free(data);
return 0; return 0;
} }
#endif #endif
@ -224,47 +226,47 @@ int main(int argc, char **argv, char **envp) {
#define TEST_NEED_SUCK #define TEST_NEED_SUCK
void *suck(int *); void *suck(int *);
int main(int argc, char **argv, char **envp) { int main(int argc, char **argv, char **envp)
char *base64; {
int base64Len; char *base64;
unsigned char *data; int base64Len;
int dataLen; unsigned char *data;
int dataLen;
base64 = (char *)suck(&base64Len); base64 = (char *)suck(&base64Len);
data = (unsigned char *)malloc(base64Len * 3/4 + 8); data = (unsigned char *)malloc(base64Len * 3/4 + 8);
dataLen = Curl_base64_decode(base64, data); dataLen = Curl_base64_decode(base64, data);
fprintf(stderr, "%d\n", dataLen); fprintf(stderr, "%d\n", dataLen);
fwrite(data,1,dataLen,stdout); fwrite(data,1,dataLen,stdout);
free(base64); free(data);
free(base64); free(data); return 0;
return 0;
} }
#endif #endif
#ifdef TEST_NEED_SUCK #ifdef TEST_NEED_SUCK
/* this function 'sucks' in as much as possible from stdin */ /* this function 'sucks' in as much as possible from stdin */
void *suck(int *lenptr) { void *suck(int *lenptr)
int cursize = 8192; {
unsigned char *buf = NULL; int cursize = 8192;
int lastread; unsigned char *buf = NULL;
int len = 0; int lastread;
int len = 0;
do { do {
cursize *= 2; cursize *= 2;
buf = (unsigned char *)realloc(buf, cursize); buf = (unsigned char *)realloc(buf, cursize);
memset(buf + len, 0, cursize - len); memset(buf + len, 0, cursize - len);
lastread = fread(buf + len, 1, cursize - len, stdin); lastread = fread(buf + len, 1, cursize - len, stdin);
len += lastread; len += lastread;
} while(!feof(stdin)); } while(!feof(stdin));
lenptr[0] = len; lenptr[0] = len;
return (void *)buf; return (void *)buf;
} }
#endif #endif
/* /*
* local variables: * local variables:
* eval: (load-file "../curl-mode.el") * eval: (load-file "../curl-mode.el")