| 1 |
|
|---|
| 2 |
for (i = 0; i < nb; i++) |
|---|
| 3 |
{ |
|---|
| 4 |
used = 0; |
|---|
| 5 |
|
|---|
| 6 |
//debug("- Block %d : O",i+1); |
|---|
| 7 |
#ifdef BENCH |
|---|
| 8 |
sprintf (filename, "/dev/null"); |
|---|
| 9 |
#else |
|---|
| 10 |
sprintf (filename, "%s%03d", nameprefix, i); |
|---|
| 11 |
#endif |
|---|
| 12 |
fo = fopen (filename, "wb"); |
|---|
| 13 |
|
|---|
| 14 |
//debug("H"); |
|---|
| 15 |
|
|---|
| 16 |
if (remaining > ALLOCLG) |
|---|
| 17 |
lg = ALLOCLG; |
|---|
| 18 |
else |
|---|
| 19 |
lg = remaining; |
|---|
| 20 |
|
|---|
| 21 |
sprintf (numline, "L%03d:", i); |
|---|
| 22 |
filestring = empty; |
|---|
| 23 |
if ((fs = fopen ("options", "rt"))) |
|---|
| 24 |
{ |
|---|
| 25 |
while (fgets (line, 400, fs)) |
|---|
| 26 |
{ |
|---|
| 27 |
line[strlen (line) - 1] = '|'; |
|---|
| 28 |
if (strstr (line, numline)) |
|---|
| 29 |
{ |
|---|
| 30 |
filestring = line + 5; |
|---|
| 31 |
break; |
|---|
| 32 |
} |
|---|
| 33 |
} |
|---|
| 34 |
fclose (fs); |
|---|
| 35 |
} |
|---|
| 36 |
|
|---|
| 37 |
bzero (header.header, HEADERLG); |
|---|
| 38 |
sprintf (header.header, "%s%sALLOCTABLELG=%d\n", firststring, |
|---|
| 39 |
filestring, lg); |
|---|
| 40 |
//debug("%s",header.header); |
|---|
| 41 |
firststring[0] = 0; |
|---|
| 42 |
bzero (header.bitmap, ALLOCLG); |
|---|
| 43 |
memcpy (header.bitmap, ptr, lg); |
|---|
| 44 |
|
|---|
| 45 |
remaining -= lg; |
|---|
| 46 |
ptr += lg; |
|---|
| 47 |
|
|---|
| 48 |
compress_init (&c, i, bytes, index); |
|---|
| 49 |
compress_data (c, (unsigned char *) &header, TOTALLG, fo, 0); |
|---|
| 50 |
|
|---|
| 51 |
//debug("D"); |
|---|
| 52 |
dataptr = buffer; |
|---|
| 53 |
datalg = 0; |
|---|
| 54 |
|
|---|
| 55 |
for (j = 0; j < lg; j++) |
|---|
| 56 |
{ |
|---|
| 57 |
//debug("%3d\b\b\b",(100*j)/lg); |
|---|
| 58 |
if (j % 200 == 0) |
|---|
| 59 |
{ |
|---|
| 60 |
#ifndef BENCH |
|---|
| 61 |
char tmp[32]; |
|---|
| 62 |
sprintf(tmp, "%llu", done); |
|---|
| 63 |
ui_send("refresh_backup_progress", 1, tmp); |
|---|
| 64 |
#endif |
|---|
| 65 |
} |
|---|
| 66 |
for (k = 1; k < 256; k += k) |
|---|
| 67 |
{ |
|---|
| 68 |
if (!(header.bitmap[j] & k)) |
|---|
| 69 |
skip += 512; |
|---|
| 70 |
else |
|---|
| 71 |
{ |
|---|
| 72 |
if (skip) |
|---|
| 73 |
{ |
|---|
| 74 |
if (lseek (fi, skip, SEEK_CUR) == -1) UI_READ_ERROR; |
|---|
| 75 |
c->cbytes += skip; |
|---|
| 76 |
} |
|---|
| 77 |
if (read (fi, dataptr, 512) != 512) UI_READ_ERROR; |
|---|
| 78 |
skip = 0; |
|---|
| 79 |
dataptr += 512; |
|---|
| 80 |
datalg += 512; |
|---|
| 81 |
used++; |
|---|
| 82 |
|
|---|
| 83 |
if (datalg == TOTALLG) |
|---|
| 84 |
{ |
|---|
| 85 |
compress_data (c, buffer, TOTALLG, fo, 0); |
|---|
| 86 |
dataptr = buffer; |
|---|
| 87 |
datalg = 0; |
|---|
| 88 |
} |
|---|
| 89 |
} |
|---|
| 90 |
} |
|---|
| 91 |
} |
|---|
| 92 |
|
|---|
| 93 |
//debug("F"); |
|---|
| 94 |
|
|---|
| 95 |
if (datalg > 0) |
|---|
| 96 |
compress_data (c, buffer, datalg, fo, 1); |
|---|
| 97 |
|
|---|
| 98 |
//debug("C"); |
|---|
| 99 |
|
|---|
| 100 |
if (skip) |
|---|
| 101 |
{ |
|---|
| 102 |
/* do not check this seek because of trailing 0 at the bitmap's end */ |
|---|
| 103 |
// fseek (fi, skip, SEEK_CUR); |
|---|
| 104 |
lseek (fi, skip, SEEK_CUR); |
|---|
| 105 |
c->cbytes += skip; |
|---|
| 106 |
skip = 0; |
|---|
| 107 |
} |
|---|
| 108 |
bytes = compress_end (c, fo); |
|---|
| 109 |
fclose (fo); |
|---|
| 110 |
|
|---|
| 111 |
//debug(". (used : %ld)\n",used); |
|---|
| 112 |
} |
|---|