summaryrefslogtreecommitdiff
path: root/src/tests/base64.cpp
blob: 3122d5c7b1331c446de497122f8623b79e3158d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "bu/file.h"
#include "bu/base64.h"

int main( int argc, char *argv[] )
{
	argc--,argv++;

	if( argc < 3 )
		return 0;

	if( argv[0][0] == 'e' )
	{
		argv++;
		Bu::File fIn( argv[0], Bu::File::Read );
		Bu::File fOut( argv[1], Bu::File::WriteNew );
		Bu::Base64 bOut( fOut );

		char buf[900];
		for(;;)
		{
			int iRead = fIn.read( buf, 900 );
			bOut.write( buf, iRead );
			if( iRead < 900 )
				break;
		}
	}
	else if( argv[0][0] == 'd' )
	{
		argv++;
		Bu::File fIn( argv[0], Bu::File::Read );
		Bu::File fOut( argv[1], Bu::File::WriteNew );
		Bu::Base64 bIn( fIn );

		char buf[16];
		for(;;)
		{
			int iRead = bIn.read( buf, 16 );
			fOut.write( buf, iRead );
			if( iRead < 16 )
				break;
		}
	}

	return 0;
}