1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include <stdio.h>
#include <values.h>
#include <stdlib.h>
#include "fileutils.h"
void dearchive(FILE * f) {
long nb;
long * address;
char fname[100];
int i;
FILE * f_out;
fread(&nb, 4, 1, f);
nb++;
fprintf(stderr, "Reading index... (%li elements)\n", nb);
address = (long *) malloc(nb * sizeof(long) + 1);
for (i = 0; i < nb; i++) {
fread(address + i, 4, 1, f);
}
address[nb] = MAXINT;
for (i = 0; i < nb; i++) {
fprintf(stderr, "Dumping file %i\n", i);
sprintf(fname, "part-%i.lz", i);
f_out = fopen(fname, "wb");
copy(fileno(f), fileno(f_out), address[i + 1] - address[i]);
fclose(f_out);
}
free(address);
}
int main(void) {
dearchive(stdin);
}
|