Full memory management support (memory.c & memory.h & mem.S)
[reactos.git] / freeldr / bootsect / split.c
1 #include <stdio.h>
2
3 FILE *in;
4 FILE *out;
5 FILE *new;
6
7 int main(int argc, char *argv[])
8 {
9 unsigned char ch;
10 int cnt;
11 int split_offset;
12
13 if (argc < 5)
14 {
15 printf("usage: split infile.bin outfile.bin newfile.bin split_offset\n");
16 return -1;
17 }
18
19 if ((in = fopen(argv[1], "rb")) == NULL)
20 {
21 printf("Couldn't open data file.\n");
22 return -1;
23 }
24 if ((out = fopen(argv[2], "wb")) == NULL)
25 {
26 printf("Couldn't open output file.\n");
27 return -1;
28 }
29 if ((new = fopen(argv[3], "wb")) == NULL)
30 {
31 printf("Couldn't open new file.\n");
32 return -1;
33 }
34
35 split_offset = atoi(argv[4]);
36
37 for (cnt=0; cnt<split_offset; cnt++)
38 {
39 ch = fgetc(in);
40 fputc(ch, out);
41 }
42
43 ch = fgetc(in);
44 while (!feof(in))
45 {
46 fputc(ch, new);
47 ch = fgetc(in);
48 }
49
50 fclose(in);
51 fclose(out);
52 fclose(new);
53
54 return 0;
55 }