author | Fionntina Carville <fionntinac@symbian.org> |
Mon, 08 Nov 2010 17:12:35 +0000 | |
changeset 109 | d76280f9c0c2 |
parent 95 | b3ffff030d5c |
permissions | -rw-r--r-- |
95
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
1 |
// base64.cpp |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
2 |
// |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
3 |
// Copyright (c) 2010 Accenture. All rights reserved. |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
4 |
// This component and the accompanying materials are made available |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
5 |
// under the terms of the "Eclipse Public License v1.0" |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
6 |
// which accompanies this distribution, and is available |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
7 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
8 |
// |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
9 |
// Initial Contributors: |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
10 |
// Accenture - Initial contribution |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
11 |
// |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
12 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
13 |
#include <fshell/ioutils.h> |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
14 |
#include <fshell/common.mmh> |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
15 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
16 |
using namespace IoUtils; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
17 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
18 |
const TInt KBlockSize = 512; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
19 |
const TInt KLineLength = 76; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
20 |
const TUint8 KBase64Chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
21 |
const TUint8 KPadCharacter = '='; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
22 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
23 |
const TUint8 KInvBase64[] = |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
24 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
25 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
26 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
27 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
28 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
29 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
30 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
31 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
32 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
33 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
34 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
35 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
36 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
37 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
38 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
39 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
40 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
41 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
42 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
43 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
44 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
45 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
46 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
47 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
48 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
49 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
50 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
51 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
52 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
53 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
54 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
55 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
56 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
57 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
58 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
59 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
60 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
61 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
62 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
63 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
64 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
65 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
66 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
67 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
68 |
0x3e, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
69 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
70 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
71 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
72 |
0x3f, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
73 |
0x34, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
74 |
0x35, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
75 |
0x36, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
76 |
0x37, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
77 |
0x38, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
78 |
0x39, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
79 |
0x3a, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
80 |
0x3b, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
81 |
0x3c, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
82 |
0x3d, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
83 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
84 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
85 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
86 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
87 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
88 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
89 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
90 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
91 |
0x1, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
92 |
0x2, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
93 |
0x3, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
94 |
0x4, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
95 |
0x5, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
96 |
0x6, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
97 |
0x7, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
98 |
0x8, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
99 |
0x9, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
100 |
0xa, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
101 |
0xb, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
102 |
0xc, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
103 |
0xd, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
104 |
0xe, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
105 |
0xf, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
106 |
0x10, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
107 |
0x11, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
108 |
0x12, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
109 |
0x13, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
110 |
0x14, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
111 |
0x15, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
112 |
0x16, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
113 |
0x17, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
114 |
0x18, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
115 |
0x19, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
116 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
117 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
118 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
119 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
120 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
121 |
0x0, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
122 |
0x1a, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
123 |
0x1b, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
124 |
0x1c, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
125 |
0x1d, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
126 |
0x1e, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
127 |
0x1f, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
128 |
0x20, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
129 |
0x21, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
130 |
0x22, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
131 |
0x23, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
132 |
0x24, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
133 |
0x25, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
134 |
0x26, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
135 |
0x27, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
136 |
0x28, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
137 |
0x29, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
138 |
0x2a, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
139 |
0x2b, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
140 |
0x2c, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
141 |
0x2d, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
142 |
0x2e, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
143 |
0x2f, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
144 |
0x30, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
145 |
0x31, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
146 |
0x32, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
147 |
0x33 |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
148 |
}; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
149 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
150 |
_LIT(KNewLine, "\r\n"); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
151 |
_LIT(KCr, "\r"); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
152 |
_LIT(KLf, "\n"); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
153 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
154 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
155 |
class CCmdBase64 : public CCommandBase |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
156 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
157 |
public: |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
158 |
static CCommandBase* NewLC(); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
159 |
~CCmdBase64(); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
160 |
private: |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
161 |
CCmdBase64(); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
162 |
void DecodeL(); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
163 |
void EncodeL(); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
164 |
private: // From CCommandBase. |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
165 |
virtual const TDesC& Name() const; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
166 |
virtual void DoRunL(); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
167 |
virtual void ArgumentsL(RCommandArgumentList& aArguments); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
168 |
virtual void OptionsL(RCommandOptionList& aOptions); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
169 |
private: |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
170 |
enum |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
171 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
172 |
EDecode, |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
173 |
EEncode |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
174 |
} iOperation; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
175 |
TFileName2 iFileName; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
176 |
TBool iVerbose; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
177 |
TBool iOverwrite; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
178 |
}; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
179 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
180 |
EXE_BOILER_PLATE(CCmdBase64) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
181 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
182 |
CCommandBase* CCmdBase64::NewLC() |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
183 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
184 |
CCmdBase64* self = new(ELeave) CCmdBase64(); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
185 |
CleanupStack::PushL(self); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
186 |
self->BaseConstructL(); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
187 |
return self; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
188 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
189 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
190 |
CCmdBase64::~CCmdBase64() |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
191 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
192 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
193 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
194 |
CCmdBase64::CCmdBase64() |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
195 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
196 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
197 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
198 |
void CCmdBase64::DecodeL() |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
199 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
200 |
if (!iOverwrite) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
201 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
202 |
LeaveIfFileExists(iFileName); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
203 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
204 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
205 |
User::LeaveIfError(Stdin().CaptureAllKeys()); // To iosrv buffering incoming data if we're not keeping up. |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
206 |
Stdin().SetReadModeL(RIoReadHandle::ELine); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
207 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
208 |
RFile file; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
209 |
LeaveIfErr(file.Replace(FsL(), iFileName, EFileWrite | EFileStream), _L("Unabled to open '%S' for writing"), &iFileName); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
210 |
CleanupClosePushL(file); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
211 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
212 |
TBuf<KLineLength + 2> lineBuf; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
213 |
TBuf8<(KLineLength / 4) * 3> outputBuf; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
214 |
TBool finished(EFalse); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
215 |
TBool started(EFalse); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
216 |
while (!finished) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
217 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
218 |
TInt err = Stdin().Read(lineBuf); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
219 |
if (err == KErrNone) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
220 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
221 |
if (iVerbose) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
222 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
223 |
Printf(_L("Read %d chars:\r\n'%S'\r\n"), lineBuf.Length(), &lineBuf); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
224 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
225 |
if ((lineBuf == KNewLine) || (lineBuf == KCr) || (lineBuf == KLf)) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
226 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
227 |
if (started) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
228 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
229 |
finished = ETrue; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
230 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
231 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
232 |
else |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
233 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
234 |
if (lineBuf.Right(2) == KNewLine) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
235 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
236 |
lineBuf.SetLength(lineBuf.Length() - 2); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
237 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
238 |
if ((lineBuf.Right(1) == KCr) || (lineBuf.Right(1) == KLf)) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
239 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
240 |
lineBuf.SetLength(lineBuf.Length() - 1); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
241 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
242 |
const TInt lineLength = lineBuf.Length(); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
243 |
if ((lineLength % 4) > 0) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
244 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
245 |
LeaveIfErr(KErrArgument, _L("Invalid base 64 encoded line (not a multiple of 4 characters in length):\r\n%S\r\n"), &lineBuf); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
246 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
247 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
248 |
started = ETrue; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
249 |
outputBuf.Zero(); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
250 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
251 |
for (TInt i = 0; i < lineLength; i += 4) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
252 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
253 |
TInt n = ((TInt)KInvBase64[lineBuf[i]] << 18) + ((TInt)KInvBase64[lineBuf[i + 1]] << 12) + ((TInt)KInvBase64[lineBuf[i + 2]] << 6) + (TInt)KInvBase64[lineBuf[i + 3]]; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
254 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
255 |
if (lineBuf[i + 2] == KPadCharacter) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
256 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
257 |
// Two pad characters |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
258 |
outputBuf.Append((n >> 16) & 0x000000FF); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
259 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
260 |
else if (lineBuf[i + 3] == KPadCharacter) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
261 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
262 |
// One pad character |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
263 |
outputBuf.Append((n >> 16) & 0x000000FF); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
264 |
outputBuf.Append((n >> 8) & 0x000000FF); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
265 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
266 |
else |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
267 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
268 |
outputBuf.Append((n >> 16) & 0x000000FF); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
269 |
outputBuf.Append((n >> 8) & 0x000000FF); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
270 |
outputBuf.Append(n & 0x000000FF); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
271 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
272 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
273 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
274 |
LeaveIfErr(file.Write(outputBuf), _L("Failed to write to '%S'"), &iFileName); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
275 |
if (iVerbose) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
276 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
277 |
Printf(_L("Wrote %d bytes to '%S'\r\n"), outputBuf.Length(), &iFileName); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
278 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
279 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
280 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
281 |
else if (err == KErrEof) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
282 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
283 |
finished = ETrue; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
284 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
285 |
else |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
286 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
287 |
LeaveIfErr(err, _L("Couldn't read STDIN")); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
288 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
289 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
290 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
291 |
CleanupStack::PopAndDestroy(&file); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
292 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
293 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
294 |
void CCmdBase64::EncodeL() |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
295 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
296 |
LeaveIfFileNotFound(iFileName); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
297 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
298 |
RFile file; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
299 |
User::LeaveIfError(file.Open(FsL(), iFileName, EFileRead | EFileStream)); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
300 |
CleanupClosePushL(file); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
301 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
302 |
TBuf8<KBlockSize> inputBuf; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
303 |
TBuf<KLineLength + 2> outputBuf; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
304 |
TBool finished(EFalse); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
305 |
while (!finished) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
306 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
307 |
TPtr8 ptr((TUint8*)inputBuf.Ptr() + inputBuf.Length(), 0, inputBuf.MaxLength() - inputBuf.Length()); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
308 |
LeaveIfErr(file.Read(ptr), _L("Couldn't read from '%S'"), &iFileName); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
309 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
310 |
if (ptr.Length() > 0) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
311 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
312 |
inputBuf.SetLength(inputBuf.Length() + ptr.Length()); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
313 |
const TInt inputBufLength = inputBuf.Length(); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
314 |
const TInt excess = inputBufLength % 3; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
315 |
const TInt bytesToProcess = inputBufLength - excess; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
316 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
317 |
for (TInt i = 0; i < bytesToProcess; i += 3) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
318 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
319 |
// Combine the next three bytes into a 24 bit number. |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
320 |
TInt n = ((TInt)inputBuf[i] << 16) + ((TInt)inputBuf[i + 1] << 8) + (TInt)inputBuf[i + 2]; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
321 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
322 |
// Split the 24-bit number into four 6-bit numbers. |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
323 |
TUint8 n0 = (TUint8)(n >> 18) & 0x3F; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
324 |
TUint8 n1 = (TUint8)(n >> 12) & 0x3F; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
325 |
TUint8 n2 = (TUint8)(n >> 6) & 0x3F; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
326 |
TUint8 n3 = (TUint8)n & 0x3F; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
327 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
328 |
// Buffer the base64 encoded equivalent. |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
329 |
outputBuf.Append(KBase64Chars[n0]); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
330 |
outputBuf.Append(KBase64Chars[n1]); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
331 |
outputBuf.Append(KBase64Chars[n2]); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
332 |
outputBuf.Append(KBase64Chars[n3]); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
333 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
334 |
// Flush output buffer if it's full. |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
335 |
if (outputBuf.Length() == KLineLength) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
336 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
337 |
outputBuf.Append(KNewLine); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
338 |
Write(outputBuf); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
339 |
outputBuf.Zero(); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
340 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
341 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
342 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
343 |
inputBuf.Delete(0, inputBufLength - excess); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
344 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
345 |
else |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
346 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
347 |
// Process what's left over in inputBuf from the previous successful read, padding as required. |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
348 |
const TInt inputBufLength = inputBuf.Length(); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
349 |
if (inputBufLength > 0) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
350 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
351 |
TInt n = (TInt)inputBuf[0] << 16; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
352 |
if (inputBufLength > 1) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
353 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
354 |
n += (TInt)inputBuf[1] << 8; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
355 |
if (inputBufLength > 2) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
356 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
357 |
n += (TInt)inputBuf[2]; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
358 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
359 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
360 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
361 |
TUint8 n0 = (TUint8)(n >> 18) & 0x3F; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
362 |
TUint8 n1 = (TUint8)(n >> 12) & 0x3F; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
363 |
TUint8 n2 = (TUint8)(n >> 6) & 0x3F; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
364 |
TUint8 n3 = (TUint8)n & 0x3F; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
365 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
366 |
outputBuf.Append(KBase64Chars[n0]); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
367 |
outputBuf.Append(KBase64Chars[n1]); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
368 |
if (inputBufLength > 1) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
369 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
370 |
outputBuf.Append(KBase64Chars[n2]); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
371 |
if (inputBufLength > 2) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
372 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
373 |
outputBuf.Append(KBase64Chars[n3]); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
374 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
375 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
376 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
377 |
for (TInt i = inputBufLength; i < 3; ++i) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
378 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
379 |
outputBuf.Append('='); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
380 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
381 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
382 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
383 |
if (outputBuf.Length() > 0) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
384 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
385 |
outputBuf.Append(KNewLine); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
386 |
Write(outputBuf); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
387 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
388 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
389 |
finished = ETrue; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
390 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
391 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
392 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
393 |
CleanupStack::PopAndDestroy(&file); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
394 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
395 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
396 |
const TDesC& CCmdBase64::Name() const |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
397 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
398 |
_LIT(KName, "base64"); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
399 |
return KName; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
400 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
401 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
402 |
void CCmdBase64::ArgumentsL(RCommandArgumentList& aArguments) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
403 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
404 |
_LIT(KArgOperation, "operation"); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
405 |
aArguments.AppendEnumL((TInt&)iOperation, KArgOperation); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
406 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
407 |
_LIT(KArgFilename, "filename"); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
408 |
aArguments.AppendFileNameL(iFileName, KArgFilename); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
409 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
410 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
411 |
void CCmdBase64::OptionsL(RCommandOptionList& aOptions) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
412 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
413 |
_LIT(KOptVerbose, "verbose"); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
414 |
aOptions.AppendBoolL(iVerbose, KOptVerbose); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
415 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
416 |
_LIT(KOptOverwrite, "overwrite"); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
417 |
aOptions.AppendBoolL(iOverwrite, KOptOverwrite); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
418 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
419 |
|
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
420 |
void CCmdBase64::DoRunL() |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
421 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
422 |
switch (iOperation) |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
423 |
{ |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
424 |
case EDecode: |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
425 |
DecodeL(); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
426 |
break; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
427 |
case EEncode: |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
428 |
EncodeL(); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
429 |
break; |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
430 |
default: |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
431 |
ASSERT(EFalse); |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
432 |
} |
b3ffff030d5c
Pulled in from FCL: input, base64, fshell thread pool
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
433 |
} |