annotate TaskManager/Test/test_render/base64_de.cpp @ 397:ce86b0186a4a draft

delete manager (in kernel/ppe/TaskManager.h) don't move.
author game@henri.cr.ie.u-ryukyu.ac.jp
date Sun, 20 Sep 2009 18:55:26 +0900
parents 028ffc9c0375
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
1 #include <iostream>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
2 #include <fstream>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
3 using namespace std;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
4
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
5 class tagTT
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
6 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
7 public:
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
8 unsigned char buf;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
9 char *cont;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
10 int nlen;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
11 };
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
12
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
13
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
14 unsigned char CtoNum(int c)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
15 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
16 if (c >= 'A' && c <= 'Z') return c-'A';
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
17 if (c >= 'a' && c <= 'z') return (c - 'a')+26;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
18 if (c >= '0' && c <= '9') return (c - '0')+52;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
19 if (c == '+') return 62;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
20 if (c == '/') return 63;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
21 return 0;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
22 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
23
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
24
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
25 int GetNumB64(tagTT &pWork)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
26 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
27 char wr;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
28 unsigned char w;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
29 unsigned char r;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
30
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
31 wr = *pWork.cont;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
32 pWork.cont++;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
33 if (wr=='\0' || wr=='=')
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
34 return -1;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
35
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
36 while(wr=='\n' || wr=='\t')
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
37 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
38 wr = *pWork.cont;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
39 pWork.cont++;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
40 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
41
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
42 w = CtoNum(wr);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
43 if (pWork.nlen == 0)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
44 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
45 unsigned char w2;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
46
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
47 wr = *pWork.cont;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
48 pWork.cont++;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
49 if (wr!='\0' && wr!='=')
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
50 w2 = CtoNum(wr);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
51 else
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
52 w2 = 0;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
53
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
54 pWork.buf = w << 2;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
55 w = w2;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
56 pWork.nlen = 6;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
57 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
58
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
59 pWork.nlen -= 2;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
60
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
61 r = pWork.buf | (w >> pWork.nlen);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
62
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
63 pWork.buf = (w << (8 - pWork.nlen));
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
64 return r;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
65 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
66
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
67
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
68 //int decode(char *cont, char *file_name)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
69 int decode(char *cont, FILE *outfile)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
70 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
71 int rw;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
72 tagTT work;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
73
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
74 //ofstream outfile(file_name);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
75
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
76 work.buf = 0;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
77 work.nlen = 0;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
78 work.cont = cont;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
79
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
80 rw = GetNumB64(work);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
81 while ( rw != -1 )
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
82 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
83 //outfile << (char)rw;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
84 putc(rw, outfile);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
85 rw = GetNumB64(work);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
86 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
87
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
88 //outfile.close();
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
89
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
90 return 0;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
91 }