diff options
Diffstat (limited to 'src/tests/base64.cpp')
-rw-r--r-- | src/tests/base64.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/tests/base64.cpp b/src/tests/base64.cpp new file mode 100644 index 0000000..4f2d68b --- /dev/null +++ b/src/tests/base64.cpp | |||
@@ -0,0 +1,45 @@ | |||
1 | #include "bu/file.h" | ||
2 | #include "bu/base64.h" | ||
3 | |||
4 | int main( int argc, char *argv[] ) | ||
5 | { | ||
6 | argc--,argv++; | ||
7 | |||
8 | if( argc < 3 ) | ||
9 | return 0; | ||
10 | |||
11 | if( argv[0][0] == 'e' ) | ||
12 | { | ||
13 | argv++; | ||
14 | Bu::File fIn( argv[0], Bu::File::Read ); | ||
15 | Bu::File fOut( argv[1], Bu::File::WriteNew ); | ||
16 | Bu::Base64 bOut( fOut, Bu::Base64::Write ); | ||
17 | |||
18 | char buf[900]; | ||
19 | for(;;) | ||
20 | { | ||
21 | int iRead = fIn.read( buf, 900 ); | ||
22 | bOut.write( buf, iRead ); | ||
23 | if( iRead < 900 ) | ||
24 | break; | ||
25 | } | ||
26 | } | ||
27 | else if( argv[0][0] == 'd' ) | ||
28 | { | ||
29 | argv++; | ||
30 | Bu::File fIn( argv[0], Bu::File::Read ); | ||
31 | Bu::File fOut( argv[1], Bu::File::WriteNew ); | ||
32 | Bu::Base64 bIn( fIn, Bu::Base64::Read ); | ||
33 | |||
34 | char buf[900]; | ||
35 | for(;;) | ||
36 | { | ||
37 | int iRead = bIn.read( buf, 900 ); | ||
38 | fOut.write( buf, iRead ); | ||
39 | if( iRead < 900 ) | ||
40 | break; | ||
41 | } | ||
42 | } | ||
43 | |||
44 | return 0; | ||
45 | } | ||