1 |
2 |
issei |
//===================================================================
|
2 |
|
|
// Module Name : RsDecodeInv
|
3 |
|
|
// File Name : RsDecodeInv.cpp
|
4 |
|
|
// Function : RTL Decoder Inverter Module generation
|
5 |
|
|
//
|
6 |
|
|
// Revision History:
|
7 |
|
|
// Date By Version Change Description
|
8 |
|
|
//===================================================================
|
9 |
|
|
// 2009/02/03 Gael Sapience 1.0 Original
|
10 |
|
|
//
|
11 |
|
|
//===================================================================
|
12 |
|
|
// (C) COPYRIGHT 2009 SYSTEM LSI CO., Ltd.
|
13 |
|
|
//
|
14 |
|
|
#include <stdio.h>
|
15 |
|
|
#include <stdlib.h>
|
16 |
|
|
#include <iostream>
|
17 |
|
|
#include<windows.h>
|
18 |
|
|
#include<fstream>
|
19 |
|
|
#include <string.h>
|
20 |
|
|
using namespace std;
|
21 |
|
|
|
22 |
|
|
FILE *OutFileDecodeInv;
|
23 |
|
|
void RsGfMultiplier( int*, int*,int*, int, int);
|
24 |
|
|
|
25 |
|
|
void RsDecodeInv(int PrimPoly, int bitSymbol, int pathFlag, int lengthPath, char *rootFolderPath) {
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
//---------------------------------------------------------------
|
29 |
|
|
// C++ variables
|
30 |
|
|
//---------------------------------------------------------------
|
31 |
|
|
int ii,zz;
|
32 |
|
|
int tempix;
|
33 |
|
|
int magicInv;
|
34 |
|
|
int MaxValue;
|
35 |
|
|
int *x1Tab;
|
36 |
|
|
int *powerTab;
|
37 |
|
|
int *y2Tab;
|
38 |
|
|
int *y3Tab;
|
39 |
|
|
int *y6Tab;
|
40 |
|
|
int *y12Tab;
|
41 |
|
|
int *y15Tab;
|
42 |
|
|
int *y30Tab;
|
43 |
|
|
int *y60Tab;
|
44 |
|
|
int *y120Tab;
|
45 |
|
|
int *y240Tab;
|
46 |
|
|
int *y14Tab;
|
47 |
|
|
int *y254Tab;
|
48 |
|
|
int *y508Tab;
|
49 |
|
|
int *y510Tab;
|
50 |
|
|
int *y1020Tab;
|
51 |
|
|
int *y1022Tab;
|
52 |
|
|
int *y62Tab;
|
53 |
|
|
int *y126Tab;
|
54 |
|
|
int *y2044Tab;
|
55 |
|
|
int *y2046Tab;
|
56 |
|
|
int *y4092Tab;
|
57 |
|
|
int *y4094Tab;
|
58 |
|
|
int *yFinalTab;
|
59 |
|
|
char *strRsDecodeInv;
|
60 |
|
|
|
61 |
|
|
x1Tab = new int[bitSymbol];
|
62 |
|
|
powerTab = new int[bitSymbol];
|
63 |
|
|
y2Tab = new int[bitSymbol];
|
64 |
|
|
y3Tab = new int[bitSymbol];
|
65 |
|
|
y6Tab = new int[bitSymbol];
|
66 |
|
|
y12Tab = new int[bitSymbol];
|
67 |
|
|
y15Tab = new int[bitSymbol];
|
68 |
|
|
y30Tab = new int[bitSymbol];
|
69 |
|
|
y60Tab = new int[bitSymbol];
|
70 |
|
|
y120Tab = new int[bitSymbol];
|
71 |
|
|
y240Tab = new int[bitSymbol];
|
72 |
|
|
y14Tab = new int[bitSymbol];
|
73 |
|
|
y254Tab = new int[bitSymbol];
|
74 |
|
|
y508Tab = new int[bitSymbol];
|
75 |
|
|
y510Tab = new int[bitSymbol];
|
76 |
|
|
y1020Tab = new int[bitSymbol];
|
77 |
|
|
y1022Tab = new int[bitSymbol];
|
78 |
|
|
y62Tab = new int[bitSymbol];
|
79 |
|
|
y126Tab = new int[bitSymbol];
|
80 |
|
|
y2044Tab = new int[bitSymbol];
|
81 |
|
|
y2046Tab = new int[bitSymbol];
|
82 |
|
|
y4092Tab = new int[bitSymbol];
|
83 |
|
|
y4094Tab = new int[bitSymbol];
|
84 |
|
|
yFinalTab= new int[bitSymbol];
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
//---------------------------------------------------------------
|
88 |
|
|
// open file
|
89 |
|
|
//---------------------------------------------------------------
|
90 |
|
|
strRsDecodeInv = (char *)calloc(lengthPath + 19, sizeof(char));
|
91 |
|
|
if (pathFlag == 0) {
|
92 |
|
|
strRsDecodeInv[0] = '.';
|
93 |
|
|
}else{
|
94 |
|
|
for(ii=0; ii<lengthPath; ii++){
|
95 |
|
|
strRsDecodeInv[ii] = rootFolderPath[ii];
|
96 |
|
|
}
|
97 |
|
|
}
|
98 |
|
|
strcat(strRsDecodeInv, "/rtl/RsDecodeInv.v");
|
99 |
|
|
|
100 |
|
|
OutFileDecodeInv = fopen(strRsDecodeInv,"w");
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
//---------------------------------------------------------------
|
105 |
|
|
// write File Header
|
106 |
|
|
//---------------------------------------------------------------
|
107 |
|
|
fprintf(OutFileDecodeInv, "//===================================================================\n");
|
108 |
|
|
fprintf(OutFileDecodeInv, "// Module Name : RsDecodeInv\n");
|
109 |
|
|
fprintf(OutFileDecodeInv, "// File Name : RsDecodeInv.v\n");
|
110 |
|
|
fprintf(OutFileDecodeInv, "// Function : Rs Decoder Inverse calculation Module\n");
|
111 |
|
|
fprintf(OutFileDecodeInv, "// \n");
|
112 |
|
|
fprintf(OutFileDecodeInv, "// Revision History:\n");
|
113 |
|
|
fprintf(OutFileDecodeInv, "// Date By Version Change Description\n");
|
114 |
|
|
fprintf(OutFileDecodeInv, "//===================================================================\n");
|
115 |
|
|
fprintf(OutFileDecodeInv, "// 2009/02/03 Gael Sapience 1.0 Original\n");
|
116 |
|
|
fprintf(OutFileDecodeInv, "//\n");
|
117 |
|
|
fprintf(OutFileDecodeInv, "//===================================================================\n");
|
118 |
|
|
fprintf(OutFileDecodeInv, "// (C) COPYRIGHT 2009 SYSTEM LSI CO., Ltd.\n");
|
119 |
|
|
fprintf(OutFileDecodeInv, "//\n\n\n");
|
120 |
|
|
|
121 |
|
|
//---------------------------------------------------------------
|
122 |
|
|
// Ports Declaration
|
123 |
|
|
//---------------------------------------------------------------
|
124 |
|
|
fprintf(OutFileDecodeInv, "module RsDecodeInv(\n");
|
125 |
|
|
fprintf(OutFileDecodeInv, " B, // data in\n");
|
126 |
|
|
fprintf(OutFileDecodeInv, " R // data out\n");
|
127 |
|
|
fprintf(OutFileDecodeInv, " );\n\n\n");
|
128 |
|
|
fprintf(OutFileDecodeInv, " input [%d:0] B; // data in\n", bitSymbol-1);
|
129 |
|
|
fprintf(OutFileDecodeInv, " output [%d:0] R; // data out\n\n\n", bitSymbol-1);
|
130 |
|
|
|
131 |
|
|
|
132 |
|
|
//---------------------------------------------------------------
|
133 |
|
|
// R register
|
134 |
|
|
//---------------------------------------------------------------
|
135 |
|
|
fprintf(OutFileDecodeInv, " reg [%d:0] R;\n\n\n", bitSymbol-1);
|
136 |
|
|
fprintf(OutFileDecodeInv, " always @(B) begin\n");
|
137 |
|
|
fprintf(OutFileDecodeInv, " case (B)\n");
|
138 |
|
|
fprintf(OutFileDecodeInv, " %d'd0: begin\n", bitSymbol);
|
139 |
|
|
fprintf(OutFileDecodeInv, " R = %d'd0;\n", bitSymbol);
|
140 |
|
|
fprintf(OutFileDecodeInv, " end\n");
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
//---------------------------------------------------------------
|
144 |
|
|
// MaxValue calculation (2^bitSymbol)
|
145 |
|
|
//---------------------------------------------------------------
|
146 |
|
|
MaxValue = 2;
|
147 |
|
|
for(ii=0; ii<(bitSymbol-1); ii++){
|
148 |
|
|
MaxValue = MaxValue*2;
|
149 |
|
|
}
|
150 |
|
|
|
151 |
|
|
|
152 |
|
|
//---------------------------------------------------------------
|
153 |
|
|
// initialize powerTab
|
154 |
|
|
//---------------------------------------------------------------
|
155 |
|
|
powerTab[0] = 1;
|
156 |
|
|
for (ii=1; ii<bitSymbol;ii++){
|
157 |
|
|
powerTab[ii] = 2*powerTab[ii-1];
|
158 |
|
|
}
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
for (ii = 1;ii<MaxValue;ii++){
|
162 |
|
|
//---------------------------------------------------------------
|
163 |
|
|
// Decimal To binary x1Tab[bin] = ii[dec]
|
164 |
|
|
//---------------------------------------------------------------
|
165 |
|
|
tempix = ii;
|
166 |
|
|
for (zz =(bitSymbol-1); zz>=0;zz--) {
|
167 |
|
|
if (tempix >= powerTab[zz]) {
|
168 |
|
|
tempix = tempix - powerTab[zz];
|
169 |
|
|
x1Tab [zz] = 1;
|
170 |
|
|
}else{
|
171 |
|
|
x1Tab [zz] = 0;
|
172 |
|
|
}
|
173 |
|
|
}
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
//---------------------------------------------------------------
|
177 |
|
|
// Galois multiplier: Y^2 = x1*x1
|
178 |
|
|
//---------------------------------------------------------------
|
179 |
|
|
RsGfMultiplier(y2Tab, x1Tab, x1Tab, PrimPoly, bitSymbol);
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
//---------------------------------------------------------------
|
183 |
|
|
// Galois multiplier: Y^3 = Y^2 *x1
|
184 |
|
|
//---------------------------------------------------------------
|
185 |
|
|
RsGfMultiplier(y3Tab, y2Tab, x1Tab, PrimPoly, bitSymbol);
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
//---------------------------------------------------------------
|
189 |
|
|
// Galois multiplier: Y^6 = Y^3 *Y^3
|
190 |
|
|
//---------------------------------------------------------------
|
191 |
|
|
RsGfMultiplier(y6Tab, y3Tab, y3Tab, PrimPoly, bitSymbol);
|
192 |
|
|
|
193 |
|
|
|
194 |
|
|
//---------------------------------------------------------------
|
195 |
|
|
// Galois multiplier: Y^12 = Y^6 *Y^6
|
196 |
|
|
//---------------------------------------------------------------
|
197 |
|
|
RsGfMultiplier(y12Tab, y6Tab, y6Tab, PrimPoly, bitSymbol);
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
//---------------------------------------------------------------
|
201 |
|
|
// Galois multiplier: Y^15 = Y^12 *Y^3
|
202 |
|
|
//---------------------------------------------------------------
|
203 |
|
|
RsGfMultiplier(y15Tab, y12Tab, y3Tab, PrimPoly, bitSymbol);
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
//---------------------------------------------------------------
|
207 |
|
|
// Galois multiplier: Y^30 = Y^15 *Y^15
|
208 |
|
|
//---------------------------------------------------------------
|
209 |
|
|
RsGfMultiplier(y30Tab, y15Tab, y15Tab, PrimPoly, bitSymbol);
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
//---------------------------------------------------------------
|
213 |
|
|
// Galois multiplier: Y^60 = Y^30 *Y^30
|
214 |
|
|
//---------------------------------------------------------------
|
215 |
|
|
RsGfMultiplier(y60Tab, y30Tab, y30Tab, PrimPoly, bitSymbol);
|
216 |
|
|
|
217 |
|
|
|
218 |
|
|
//---------------------------------------------------------------
|
219 |
|
|
// Galois multiplier: Y^62 = Y^60 *Y^2
|
220 |
|
|
//---------------------------------------------------------------
|
221 |
|
|
RsGfMultiplier(y62Tab, y60Tab, y2Tab, PrimPoly, bitSymbol);
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
//---------------------------------------------------------------
|
225 |
|
|
// Galois multiplier: Y^120 = Y^60 *Y^60
|
226 |
|
|
//---------------------------------------------------------------
|
227 |
|
|
RsGfMultiplier(y120Tab, y60Tab, y60Tab, PrimPoly, bitSymbol);
|
228 |
|
|
|
229 |
|
|
|
230 |
|
|
//---------------------------------------------------------------
|
231 |
|
|
// Galois multiplier: Y^126 = Y^120 *Y^6
|
232 |
|
|
//---------------------------------------------------------------
|
233 |
|
|
RsGfMultiplier(y126Tab, y120Tab, y6Tab, PrimPoly, bitSymbol);
|
234 |
|
|
|
235 |
|
|
|
236 |
|
|
//---------------------------------------------------------------
|
237 |
|
|
// Galois multiplier: Y^240 = Y^120 *Y^120
|
238 |
|
|
//---------------------------------------------------------------
|
239 |
|
|
RsGfMultiplier(y240Tab, y120Tab, y120Tab, PrimPoly, bitSymbol);
|
240 |
|
|
|
241 |
|
|
|
242 |
|
|
//---------------------------------------------------------------
|
243 |
|
|
// Galois multiplier: Y^14 = Y^12 *Y^2
|
244 |
|
|
//---------------------------------------------------------------
|
245 |
|
|
RsGfMultiplier(y14Tab, y12Tab, y2Tab, PrimPoly, bitSymbol);
|
246 |
|
|
|
247 |
|
|
|
248 |
|
|
//---------------------------------------------------------------
|
249 |
|
|
// Galois multiplier: Y^254 = Y^240 *Y^14
|
250 |
|
|
//---------------------------------------------------------------
|
251 |
|
|
RsGfMultiplier(y254Tab, y240Tab, y14Tab, PrimPoly, bitSymbol);
|
252 |
|
|
|
253 |
|
|
|
254 |
|
|
//---------------------------------------------------------------
|
255 |
|
|
// Galois multiplier: Y^508 = Y^254 *Y^254
|
256 |
|
|
//---------------------------------------------------------------
|
257 |
|
|
RsGfMultiplier(y508Tab, y254Tab, y254Tab, PrimPoly, bitSymbol);
|
258 |
|
|
|
259 |
|
|
|
260 |
|
|
//---------------------------------------------------------------
|
261 |
|
|
// Galois multiplier: Y^510 = Y^508 *Y^2
|
262 |
|
|
//---------------------------------------------------------------
|
263 |
|
|
RsGfMultiplier(y510Tab, y508Tab, y2Tab, PrimPoly, bitSymbol);
|
264 |
|
|
|
265 |
|
|
|
266 |
|
|
//---------------------------------------------------------------
|
267 |
|
|
// Galois multiplier: Y^1020 = Y^510 *Y^510
|
268 |
|
|
//---------------------------------------------------------------
|
269 |
|
|
RsGfMultiplier(y1020Tab, y510Tab, y510Tab, PrimPoly, bitSymbol);
|
270 |
|
|
|
271 |
|
|
|
272 |
|
|
//---------------------------------------------------------------
|
273 |
|
|
// Galois multiplier: Y^1022 = Y^1020 *Y^2
|
274 |
|
|
//---------------------------------------------------------------
|
275 |
|
|
RsGfMultiplier(y1022Tab, y1020Tab, y2Tab, PrimPoly, bitSymbol);
|
276 |
|
|
|
277 |
|
|
|
278 |
|
|
//---------------------------------------------------------------
|
279 |
|
|
// Galois multiplier: Y^2044 = Y^1022 *Y^1022
|
280 |
|
|
//---------------------------------------------------------------
|
281 |
|
|
RsGfMultiplier(y2044Tab, y1022Tab, y1022Tab, PrimPoly, bitSymbol);
|
282 |
|
|
|
283 |
|
|
|
284 |
|
|
//---------------------------------------------------------------
|
285 |
|
|
// Galois multiplier: Y^2044 = Y^2044 *Y^2
|
286 |
|
|
//---------------------------------------------------------------
|
287 |
|
|
RsGfMultiplier(y2046Tab, y2044Tab, y2Tab, PrimPoly, bitSymbol);
|
288 |
|
|
|
289 |
|
|
|
290 |
|
|
//---------------------------------------------------------------
|
291 |
|
|
// Galois multiplier: Y^4092 = Y^2046 *Y^2046
|
292 |
|
|
//---------------------------------------------------------------
|
293 |
|
|
RsGfMultiplier(y4092Tab, y2046Tab, y2046Tab, PrimPoly, bitSymbol);
|
294 |
|
|
|
295 |
|
|
|
296 |
|
|
//---------------------------------------------------------------
|
297 |
|
|
// Galois multiplier: Y^4094 = Y^4092 *Y^2
|
298 |
|
|
//---------------------------------------------------------------
|
299 |
|
|
RsGfMultiplier(y4094Tab, y4092Tab, y2Tab, PrimPoly, bitSymbol);
|
300 |
|
|
|
301 |
|
|
|
302 |
|
|
//---------------------------------------------------------------
|
303 |
|
|
// Result assignment 2^8=y^254, 2^9=y^510, 2^10=y^1022
|
304 |
|
|
//---------------------------------------------------------------
|
305 |
|
|
switch(bitSymbol){
|
306 |
|
|
case (3):
|
307 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
308 |
|
|
yFinalTab [zz] = y6Tab[zz];
|
309 |
|
|
}
|
310 |
|
|
break;
|
311 |
|
|
case (4):
|
312 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
313 |
|
|
yFinalTab [zz] = y14Tab[zz];
|
314 |
|
|
}
|
315 |
|
|
break;
|
316 |
|
|
case (5):
|
317 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
318 |
|
|
yFinalTab [zz] = y30Tab[zz];
|
319 |
|
|
}
|
320 |
|
|
break;
|
321 |
|
|
case (6):
|
322 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
323 |
|
|
yFinalTab [zz] = y62Tab[zz];
|
324 |
|
|
}
|
325 |
|
|
break;
|
326 |
|
|
case (7):
|
327 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
328 |
|
|
yFinalTab [zz] = y126Tab[zz];
|
329 |
|
|
}
|
330 |
|
|
break;
|
331 |
|
|
case (8):
|
332 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
333 |
|
|
yFinalTab [zz] = y254Tab[zz];
|
334 |
|
|
}
|
335 |
|
|
break;
|
336 |
|
|
case (9):
|
337 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
338 |
|
|
yFinalTab [zz] = y510Tab[zz];
|
339 |
|
|
}
|
340 |
|
|
break;
|
341 |
|
|
case (10):
|
342 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
343 |
|
|
yFinalTab [zz] = y1022Tab[zz];
|
344 |
|
|
}
|
345 |
|
|
break;
|
346 |
|
|
case (11):
|
347 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
348 |
|
|
yFinalTab [zz] = y2046Tab[zz];
|
349 |
|
|
}
|
350 |
|
|
break;
|
351 |
|
|
case (12):
|
352 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
353 |
|
|
yFinalTab [zz] = y4094Tab[zz];
|
354 |
|
|
}
|
355 |
|
|
break;
|
356 |
|
|
default:
|
357 |
|
|
yFinalTab [0] = 0;
|
358 |
|
|
break;
|
359 |
|
|
}
|
360 |
|
|
|
361 |
|
|
|
362 |
|
|
//---------------------------------------------------------------
|
363 |
|
|
// Binary To Decimal magicInv[dec] = yFinalTab[bin]
|
364 |
|
|
//---------------------------------------------------------------
|
365 |
|
|
magicInv = 0;
|
366 |
|
|
for (zz=0; zz<bitSymbol;zz++){
|
367 |
|
|
magicInv = magicInv + yFinalTab[zz] * powerTab[zz];
|
368 |
|
|
}
|
369 |
|
|
|
370 |
|
|
// fprintf(OutFileDecodeInv, " %d'd%d: begin\n", bitSymbol, ii);
|
371 |
|
|
if (ii == MaxValue -1){
|
372 |
|
|
fprintf(OutFileDecodeInv, " default: begin\n");
|
373 |
|
|
}else{
|
374 |
|
|
fprintf(OutFileDecodeInv, " %d'd%d: begin\n", bitSymbol, ii);
|
375 |
|
|
}
|
376 |
|
|
|
377 |
|
|
|
378 |
|
|
fprintf(OutFileDecodeInv, " R = %d'd%d;\n", bitSymbol, magicInv);
|
379 |
|
|
fprintf(OutFileDecodeInv, " end\n");
|
380 |
|
|
}
|
381 |
|
|
fprintf(OutFileDecodeInv, " endcase\n");
|
382 |
|
|
fprintf(OutFileDecodeInv, " end\n");
|
383 |
|
|
fprintf(OutFileDecodeInv, "endmodule\n");
|
384 |
|
|
|
385 |
|
|
|
386 |
|
|
//---------------------------------------------------------------
|
387 |
|
|
// close file
|
388 |
|
|
//---------------------------------------------------------------
|
389 |
|
|
fclose(OutFileDecodeInv);
|
390 |
|
|
|
391 |
|
|
|
392 |
|
|
//---------------------------------------------------------------
|
393 |
|
|
// Free memory
|
394 |
|
|
//---------------------------------------------------------------
|
395 |
|
|
delete[] x1Tab;
|
396 |
|
|
delete[] powerTab;
|
397 |
|
|
delete[] y2Tab;
|
398 |
|
|
delete[] y3Tab;
|
399 |
|
|
delete[] y6Tab;
|
400 |
|
|
delete[] y12Tab;
|
401 |
|
|
delete[] y15Tab;
|
402 |
|
|
delete[] y30Tab;
|
403 |
|
|
delete[] y60Tab;
|
404 |
|
|
delete[] y120Tab;
|
405 |
|
|
delete[] y240Tab;
|
406 |
|
|
delete[] y14Tab;
|
407 |
|
|
delete[] y254Tab;
|
408 |
|
|
delete[] y508Tab;
|
409 |
|
|
delete[] y510Tab;
|
410 |
|
|
delete[] y1020Tab;
|
411 |
|
|
delete[] y1022Tab;
|
412 |
|
|
delete[] yFinalTab;
|
413 |
|
|
delete[] y62Tab;
|
414 |
|
|
delete[] y126Tab;
|
415 |
|
|
delete[] y2044Tab;
|
416 |
|
|
delete[] y2046Tab;
|
417 |
|
|
delete[] y4092Tab;
|
418 |
|
|
delete[] y4094Tab;
|
419 |
|
|
|
420 |
|
|
|
421 |
|
|
//---------------------------------------------------------------
|
422 |
|
|
// automatically convert Dos mode To Unix mode
|
423 |
|
|
//---------------------------------------------------------------
|
424 |
|
|
char ch;
|
425 |
|
|
char temp[MAX_PATH]="\0";
|
426 |
|
|
|
427 |
|
|
//Open the file for reading in binarymode.
|
428 |
|
|
ifstream fp_read(strRsDecodeInv, ios_base::in | ios_base::binary);
|
429 |
|
|
sprintf(temp, "%s.temp", strRsDecodeInv);
|
430 |
|
|
//Create a temporary file for writing in the binary mode. This
|
431 |
|
|
//file will be created in the same directory as the input file.
|
432 |
|
|
ofstream fp_write(temp, ios_base::out | ios_base::trunc | ios_base::binary);
|
433 |
|
|
|
434 |
|
|
while(fp_read.eof() != true)
|
435 |
|
|
{
|
436 |
|
|
fp_read.get(ch);
|
437 |
|
|
//Check for CR (carriage return)
|
438 |
|
|
if((int)ch == 0x0D)
|
439 |
|
|
continue;
|
440 |
|
|
if (!fp_read.eof())fp_write.put(ch);
|
441 |
|
|
}
|
442 |
|
|
|
443 |
|
|
fp_read.close();
|
444 |
|
|
fp_write.close();
|
445 |
|
|
//Delete the existing input file.
|
446 |
|
|
remove(strRsDecodeInv);
|
447 |
|
|
//Rename the temporary file to the input file.
|
448 |
|
|
rename(temp, strRsDecodeInv);
|
449 |
|
|
//Delete the temporary file.
|
450 |
|
|
remove(temp);
|
451 |
|
|
|
452 |
|
|
|
453 |
|
|
//---------------------------------------------------------------
|
454 |
|
|
// clean string
|
455 |
|
|
//---------------------------------------------------------------
|
456 |
|
|
free(strRsDecodeInv);
|
457 |
|
|
|
458 |
|
|
|
459 |
|
|
}
|