3 * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/
5 * Copyright (C) 2001 "timecop" <timecop@japan.co.jp>
7 * Copyright (C) 2002 Florian Schulze <crow@icculus.org>
9 * Portions of this code are from the MPEG software simulation group
10 * idct implementation. This code will be replaced with a new
11 * implementation soon.
13 * This file is part of Jump'n'Bump.
15 * Jump'n'Bump is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * Jump'n'Bump is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 #include <sys/types.h>
39 typedef unsigned int u_int32_t;
48 int main(int argc, char **argv)
55 printf("dumbass, specify filename to unpack\n");
59 fd = open(argv[1], O_RDONLY | O_BINARY);
61 perror("open datafile");
64 /* get number of entries */
65 read(fd, &num_entries, 4);
67 printf("%d entries in datafile\n", num_entries);
69 datafile = calloc(num_entries, sizeof(DirEntry));
70 read(fd, datafile, num_entries * sizeof(DirEntry));
71 printf("Directory Listing:\n");
72 for (i = 0; i < num_entries; i++) {
74 memset(filename, 0, sizeof(filename));
75 strncpy(filename, datafile[i].filename, 12);
76 printf("%02d:\t%s (%u bytes)\n", i, filename,
80 for (i = 0; i < num_entries; i++) {
84 memset(filename, 0, sizeof(filename));
85 strncpy(filename, datafile[i].filename, 12);
86 printf("Extracting %s ", filename);
88 outfd = open(filename, O_RDWR | O_CREAT | O_BINARY, 0644);
90 perror("cant open file");
93 lseek(fd, datafile[i].offset, SEEK_SET);
94 buf = calloc(1, datafile[i].size + 16);
95 read(fd, buf, datafile[i].size);
96 write(outfd, buf, datafile[i].size);