2 * Taken from the public domain ansitape program for
3 * integration into Bacula. KES - Mar 2005
6 Bacula® - The Network Backup Solution
8 Copyright (C) 2006-2006 Free Software Foundation Europe e.V.
10 The main author of Bacula is Kern Sibbald, with contributions from
11 many others, a complete list can be found in the file AUTHORS.
12 This program is Free Software; you can redistribute it and/or
13 modify it under the terms of version two of the GNU General Public
14 License as published by the Free Software Foundation and included
17 This program is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
27 Bacula® is a registered trademark of Kern Sibbald.
28 The licensor of Bacula is the Free Software Foundation Europe
29 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
30 Switzerland, email:ftf@fsfeurope.org.
34 /* Mapping of EBCDIC codes to ASCII equivalents. */
35 static char to_ascii_table[256] = {
36 '\000', '\001', '\002', '\003',
37 '\234', '\011', '\206', '\177',
38 '\227', '\215', '\216', '\013',
39 '\014', '\015', '\016', '\017',
40 '\020', '\021', '\022', '\023',
41 '\235', '\205', '\010', '\207',
42 '\030', '\031', '\222', '\217',
43 '\034', '\035', '\036', '\037',
44 '\200', '\201', '\202', '\203',
45 '\204', '\012', '\027', '\033',
46 '\210', '\211', '\212', '\213',
47 '\214', '\005', '\006', '\007',
48 '\220', '\221', '\026', '\223',
49 '\224', '\225', '\226', '\004',
50 '\230', '\231', '\232', '\233',
51 '\024', '\025', '\236', '\032',
52 '\040', '\240', '\241', '\242',
53 '\243', '\244', '\245', '\246',
54 '\247', '\250', '\133', '\056',
55 '\074', '\050', '\053', '\041',
56 '\046', '\251', '\252', '\253',
57 '\254', '\255', '\256', '\257',
58 '\260', '\261', '\135', '\044',
59 '\052', '\051', '\073', '\136',
60 '\055', '\057', '\262', '\263',
61 '\264', '\265', '\266', '\267',
62 '\270', '\271', '\174', '\054',
63 '\045', '\137', '\076', '\077',
64 '\272', '\273', '\274', '\275',
65 '\276', '\277', '\300', '\301',
66 '\302', '\140', '\072', '\043',
67 '\100', '\047', '\075', '\042',
68 '\303', '\141', '\142', '\143',
69 '\144', '\145', '\146', '\147',
70 '\150', '\151', '\304', '\305',
71 '\306', '\307', '\310', '\311',
72 '\312', '\152', '\153', '\154',
73 '\155', '\156', '\157', '\160',
74 '\161', '\162', '\313', '\314',
75 '\315', '\316', '\317', '\320',
76 '\321', '\176', '\163', '\164',
77 '\165', '\166', '\167', '\170',
78 '\171', '\172', '\322', '\323',
79 '\324', '\325', '\326', '\327',
80 '\330', '\331', '\332', '\333',
81 '\334', '\335', '\336', '\337',
82 '\340', '\341', '\342', '\343',
83 '\344', '\345', '\346', '\347',
84 '\173', '\101', '\102', '\103',
85 '\104', '\105', '\106', '\107',
86 '\110', '\111', '\350', '\351',
87 '\352', '\353', '\354', '\355',
88 '\175', '\112', '\113', '\114',
89 '\115', '\116', '\117', '\120',
90 '\121', '\122', '\356', '\357',
91 '\360', '\361', '\362', '\363',
92 '\134', '\237', '\123', '\124',
93 '\125', '\126', '\127', '\130',
94 '\131', '\132', '\364', '\365',
95 '\366', '\367', '\370', '\371',
96 '\060', '\061', '\062', '\063',
97 '\064', '\065', '\066', '\067',
98 '\070', '\071', '\372', '\373',
99 '\374', '\375', '\376', '\377'
103 /* Mapping of ASCII codes to EBCDIC equivalents. */
104 static char to_ebcdic_table[256] = {
105 '\000', '\001', '\002', '\003',
106 '\067', '\055', '\056', '\057',
107 '\026', '\005', '\045', '\013',
108 '\014', '\015', '\016', '\017',
109 '\020', '\021', '\022', '\023',
110 '\074', '\075', '\062', '\046',
111 '\030', '\031', '\077', '\047',
112 '\034', '\035', '\036', '\037',
113 '\100', '\117', '\177', '\173',
114 '\133', '\154', '\120', '\175',
115 '\115', '\135', '\134', '\116',
116 '\153', '\140', '\113', '\141',
117 '\360', '\361', '\362', '\363',
118 '\364', '\365', '\366', '\367',
119 '\370', '\371', '\172', '\136',
120 '\114', '\176', '\156', '\157',
121 '\174', '\301', '\302', '\303',
122 '\304', '\305', '\306', '\307',
123 '\310', '\311', '\321', '\322',
124 '\323', '\324', '\325', '\326',
125 '\327', '\330', '\331', '\342',
126 '\343', '\344', '\345', '\346',
127 '\347', '\350', '\351', '\112',
128 '\340', '\132', '\137', '\155',
129 '\171', '\201', '\202', '\203',
130 '\204', '\205', '\206', '\207',
131 '\210', '\211', '\221', '\222',
132 '\223', '\224', '\225', '\226',
133 '\227', '\230', '\231', '\242',
134 '\243', '\244', '\245', '\246',
135 '\247', '\250', '\251', '\300',
136 '\152', '\320', '\241', '\007',
137 '\040', '\041', '\042', '\043',
138 '\044', '\025', '\006', '\027',
139 '\050', '\051', '\052', '\053',
140 '\054', '\011', '\012', '\033',
141 '\060', '\061', '\032', '\063',
142 '\064', '\065', '\066', '\010',
143 '\070', '\071', '\072', '\073',
144 '\004', '\024', '\076', '\341',
145 '\101', '\102', '\103', '\104',
146 '\105', '\106', '\107', '\110',
147 '\111', '\121', '\122', '\123',
148 '\124', '\125', '\126', '\127',
149 '\130', '\131', '\142', '\143',
150 '\144', '\145', '\146', '\147',
151 '\150', '\151', '\160', '\161',
152 '\162', '\163', '\164', '\165',
153 '\166', '\167', '\170', '\200',
154 '\212', '\213', '\214', '\215',
155 '\216', '\217', '\220', '\232',
156 '\233', '\234', '\235', '\236',
157 '\237', '\240', '\252', '\253',
158 '\254', '\255', '\256', '\257',
159 '\260', '\261', '\262', '\263',
160 '\264', '\265', '\266', '\267',
161 '\270', '\271', '\272', '\273',
162 '\274', '\275', '\276', '\277',
163 '\312', '\313', '\314', '\315',
164 '\316', '\317', '\332', '\333',
165 '\334', '\335', '\336', '\337',
166 '\352', '\353', '\354', '\355',
167 '\356', '\357', '\372', '\373',
168 '\374', '\375', '\376', '\377'
173 * Convert from ASCII to EBCDIC
175 void ascii_to_ebcdic(char *dst, char *src, int count)
178 *dst++ = to_ebcdic_table[0377 & *src++];
184 * Convert from EBCDIC to ASCII
186 void ebcdic_to_ascii(char *dst, char *src, int count)
189 *dst++ = to_ascii_table[0377 & *src++];