Go to the SVN repository for this file.
40 # define MaybeUInt64_FMT "%Lu" 44 # define MaybeUInt64_FMT "%I64u" 47 # define MaybeUInt64_FMT "%u" 55 typedef unsigned char Bool;
56 #define True ((Bool)1) 57 #define False ((Bool)0) 60 #define BZ_MAX_FILENAME 2000 88 "%s: I/O error reading `%s', possible reason follows.\n",
91fprintf ( stderr,
"%s: warning: output file(s) may be incomplete.\n",
101 "%s: I/O error reading `%s', possible reason follows.\n",
104fprintf ( stderr,
"%s: warning: output file(s) may be incomplete.\n",
114 "%s: malloc failed on request for %d bytes.\n",
116fprintf ( stderr,
"%s: warning: output file(s) may be incomplete.\n",
126 "%s: `%s' appears to contain more than %d blocks\n",
129 "%s: and cannot be handled. To fix, increase\n",
132 "%s: BZ_MAX_HANDLED_BLOCKS in bzip2recover.c, and recompile.\n",
206 if( retVal == EOF ) {
212 return( ((bs->
buffer) >> 7) & 0x1 );
222 if( bs->
mode==
'w') {
230retVal = fflush ( bs->
handle);
233retVal = fclose ( bs->
handle);
245 for(
i= 7;
i>= 0;
i--)
255 for(
i= 31;
i>= 0;
i--)
263 Int32 n= strlen ( name );
264 if(
n<= 4)
return False;
266(name[
n-4] ==
'.'&&
267name[
n-3] ==
'b'&&
268name[
n-2] ==
'z'&&
269name[
n-1] ==
'2');
279 # define BZ_SPLIT_SYM '\\' 281 # define BZ_SPLIT_SYM '/' 284 #define BLOCK_HEADER_HI 0x00003141UL 285 #define BLOCK_HEADER_LO 0x59265359UL 287 #define BLOCK_ENDMARK_HI 0x00001772UL 288 #define BLOCK_ENDMARK_LO 0x45385090UL 294 #define BZ_MAX_HANDLED_BLOCKS 50000 306 Int32 b, wrBlock, currBlock, rbCtr;
309 UInt32buffHi, buffLo, blockCRC;
317 "bzip2recover 1.0.8: extracts blocks from damaged .bz2 files.\n");
320fprintf ( stderr,
"%s: usage is `%s damaged_file_name'.\n",
325 "\trestrictions on size of recovered file: None\n");
329 "\trestrictions on size of recovered file: 512 MB\n");
331 "\tto circumvent, recompile with MaybeUInt64 as an\n" 332 "\tunsigned 64-bit int.\n");
336 "\tsizeof(MaybeUInt64) is not 4 or 8 -- " 337 "configuration error.\n");
345 "%s: supplied filename is suspiciously (>= %d chars) long. Bye!\n",
346 progName, (
int)strlen(argv[1]) );
353 if(inFile ==
NULL) {
359fprintf ( stderr,
"%s: searching for block boundaries ...\n",
progName);
372 if(bitsRead >=
bStart[currBlock] &&
373(bitsRead -
bStart[currBlock]) >= 40) {
374 bEnd[currBlock] = bitsRead-1;
378currBlock,
bStart[currBlock],
bEnd[currBlock] );
383buffHi = (buffHi << 1) | (buffLo >> 31);
384buffLo = (buffLo << 1) | (
b& 1);
392 bEnd[currBlock] = bitsRead-49;
394 bEnd[currBlock] = 0;
397(
bEnd[currBlock] -
bStart[currBlock]) >= 130) {
400rbCtr+1,
bStart[currBlock],
bEnd[currBlock] );
409 bStart[currBlock] = bitsRead;
419 "%s: sorry, I couldn't find any block boundaries.\n",
424fprintf ( stderr,
"%s: splitting into blocks\n",
progName);
427 if(inFile ==
NULL) {
434blockCRC = 0; bsWr = 0;
442buffHi = (buffHi << 1) | (buffLo >> 31);
443buffLo = (buffLo << 1) | (
b& 1);
444 if(bitsRead == 47+
rbStart[wrBlock])
445blockCRC = (buffHi << 16) | (buffLo >> 16);
447 if(outFile !=
NULL&& bitsRead >=
rbStart[wrBlock]
448&& bitsRead <=
rbEnd[wrBlock]) {
454 if(bitsRead ==
rbEnd[wrBlock]+1) {
455 if(outFile !=
NULL) {
463 if(wrBlock >= rbCtr)
break;
466 if(bitsRead ==
rbStart[wrBlock]) {
482sprintf (
split,
"rec%5d", wrBlock+1);
483 for(p =
split; *p != 0; p++)
if(*p ==
' ') *p =
'0';
488fprintf ( stderr,
" writing block %d to `%s' ...\n",
492 if(outFile ==
NULL) {
493fprintf ( stderr,
"%s: can't write `%s'\n",
508fprintf ( stderr,
"%s: finished\n",
progName);
static Int32 bsGetBit(BitStream *bs)
static BitStream * bsOpenWriteStream(FILE *stream)
static Bool endsInBz2(Char *name)
static void bsPutUChar(BitStream *bs, UChar c)
MaybeUInt64 rbStart[50000]
static void bsPutUInt32(BitStream *bs, UInt32 c)
#define BZ_MAX_HANDLED_BLOCKS
static void writeError(void)
static void bsClose(BitStream *bs)
static void tooManyBlocks(Int32 max_handled_blocks)
MaybeUInt64 bStart[50000]
Int32 main(Int32 argc, Char **argv)
static BitStream * bsOpenReadStream(FILE *stream)
static void mallocFail(Int32 n)
static void readError(void)
static void bsPutBit(BitStream *bs, Int32 bit)
char Char
Alias for char.
void split(std::vector< std::string > *strVec, const std::string &str_, const std::string &split_)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4