extractor-gtk-cvslog Mailing List for Obscure-Extractor-GTK (Page 3)
Extract files from unusual archive formats
Brought to you by:
someone-guy
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(8) |
Sep
(19) |
Oct
(1) |
Nov
|
Dec
|
2008 |
Jan
|
Feb
(19) |
Mar
(6) |
Apr
(6) |
May
(2) |
Jun
|
Jul
|
Aug
(31) |
Sep
(2) |
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <som...@us...> - 2008-04-06 20:09:23
|
Revision: 74 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=74&view=rev Author: someone-guy Date: 2008-04-06 13:09:20 -0700 (Sun, 06 Apr 2008) Log Message: ----------- Move add_entry to global helpers.c/h Modified Paths: -------------- trunk/extractor/generic.c trunk/extractor/helpers.c trunk/extractor/helpers.h Modified: trunk/extractor/generic.c =================================================================== --- trunk/extractor/generic.c 2008-04-06 20:08:48 UTC (rev 73) +++ trunk/extractor/generic.c 2008-04-06 20:09:20 UTC (rev 74) @@ -17,15 +17,6 @@ return 0; } -static void add_entry(file_t **list, int cnt, const char *ext) { - file_t *l = *list; - l = realloc(l, (cnt + 2) * sizeof(file_t)); - memset(&l[cnt + 1], 0, sizeof(file_t)); - l[cnt].name = malloc(50); - snprintf(l[cnt].name, 50, "%i.%s", cnt, ext); - *list = l; -} - static int is_valid_fourcc(uint32_t id) { static const char valid_chars[] = "0123456789abcdefghijklmnopqrstuvwxyz" Modified: trunk/extractor/helpers.c =================================================================== --- trunk/extractor/helpers.c 2008-04-06 20:08:48 UTC (rev 73) +++ trunk/extractor/helpers.c 2008-04-06 20:09:20 UTC (rev 74) @@ -7,6 +7,7 @@ */ #include <stdlib.h> #include <stdio.h> +#include <string.h> #include <inttypes.h> #include "helpers.h" #include "formats.h" @@ -67,6 +68,21 @@ return t[0] << 8 | t[1]; } +/** + * \brief append a new entry to a file list + * \param list file list to append to + * \param cnt current number of entries in list + * \param ext extension of entry to add + */ +void add_entry(struct file_s **list, int cnt, const char *ext) { + file_t *l = *list; + l = realloc(l, (cnt + 2) * sizeof(file_t)); + memset(&l[cnt + 1], 0, sizeof(file_t)); + l[cnt].name = malloc(50); + snprintf(l[cnt].name, 50, "%i.%s", cnt, ext); + *list = l; +} + #define BLOCK_SIZE 4096 /** * \brief copy data from one file into another Modified: trunk/extractor/helpers.h =================================================================== --- trunk/extractor/helpers.h 2008-04-06 20:08:48 UTC (rev 73) +++ trunk/extractor/helpers.h 2008-04-06 20:09:20 UTC (rev 74) @@ -11,6 +11,7 @@ #define HUGETAG(a, b, c, d, e, f, g, h) (((uint64_t)(TAG(a, b, c, d)) << 32) | TAG(e, f, g, h)) struct file_s; +void add_entry(struct file_s **list, int cnt, const char *ext); void default_free_list(struct file_s *list); void default_free_ignorepriv(struct file_s *list); int default_extract_file(FILE *in, const struct file_s *file, FILE *out); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-04-06 20:08:52
|
Revision: 73 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=73&view=rev Author: someone-guy Date: 2008-04-06 13:08:48 -0700 (Sun, 06 Apr 2008) Log Message: ----------- Add read_be16 helper Modified Paths: -------------- trunk/extractor/helpers.c trunk/extractor/helpers.h Modified: trunk/extractor/helpers.c =================================================================== --- trunk/extractor/helpers.c 2008-03-08 21:14:45 UTC (rev 72) +++ trunk/extractor/helpers.c 2008-04-06 20:08:48 UTC (rev 73) @@ -60,6 +60,13 @@ return t[1] << 8 | t[0]; } +//! read a 16 bit big-endian value from file +uint16_t read_be16(FILE *f) { + unsigned char t[2]; + fread(t, 2, 1, f); + return t[0] << 8 | t[1]; +} + #define BLOCK_SIZE 4096 /** * \brief copy data from one file into another Modified: trunk/extractor/helpers.h =================================================================== --- trunk/extractor/helpers.h 2008-03-08 21:14:45 UTC (rev 72) +++ trunk/extractor/helpers.h 2008-04-06 20:08:48 UTC (rev 73) @@ -5,6 +5,7 @@ uint32_t read_le32(FILE *f); uint32_t peek_le32(FILE *f); uint32_t read_be32(FILE *f); +uint16_t read_be16(FILE *f); int fcopy(FILE *in, FILE *out, int len); #define TAG(a, b, c, d) ((uint32_t)((a) << 8 | (b)) << 16 | ((c) << 8 | (d))) #define HUGETAG(a, b, c, d, e, f, g, h) (((uint64_t)(TAG(a, b, c, d)) << 32) | TAG(e, f, g, h)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-03-08 21:14:47
|
Revision: 72 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=72&view=rev Author: someone-guy Date: 2008-03-08 13:14:45 -0800 (Sat, 08 Mar 2008) Log Message: ----------- Make it easier to use hacks for Windows compilation. Modified Paths: -------------- trunk/extractor/Makefile Modified: trunk/extractor/Makefile =================================================================== --- trunk/extractor/Makefile 2008-03-08 21:12:54 UTC (rev 71) +++ trunk/extractor/Makefile 2008-03-08 21:14:45 UTC (rev 72) @@ -1,5 +1,8 @@ CC=gcc CFLAGS=-Wall -Wdeclaration-after-statement -Wpointer-arith -Wredundant-decls -Wcast-qual -Wwrite-strings -g -O2 +GTKFLAGS=`pkg-config --cflags --libs gtk+-2.0` +#GTKFLAGS=-mms-bitfields -Iinclude libglib-2.0-0.dll libgobject-2.0-0.dll libgdk-win32-2.0-0.dll libgdk_pixbuf-2.0-0.dll libgtk-win32-2.0-0.dll intl.dll +#GTKFLAGS+=-mwindows MODULES= \ bloodrayne.c \ generic.c \ @@ -12,7 +15,7 @@ all: extractor extractor: extractor.c helpers.c helpers.h formats.h $(MODULES) - $(CC) $(CFLAGS) -o extractor extractor.c helpers.c $(MODULES) `pkg-config --cflags --libs gtk+-2.0` + $(CC) $(CFLAGS) -o extractor extractor.c helpers.c $(MODULES) $(GTKFLAGS) clean: rm -f extractor *.o This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-03-08 21:12:56
|
Revision: 71 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=71&view=rev Author: someone-guy Date: 2008-03-08 13:12:54 -0800 (Sat, 08 Mar 2008) Log Message: ----------- Add a extract-to-memory function for preview since Windows has no sane way to handle temporary files. Modified Paths: -------------- trunk/extractor/bloodrayne.c trunk/extractor/extractor.c trunk/extractor/formats.h trunk/extractor/generic.c trunk/extractor/helpers.c trunk/extractor/helpers.h trunk/extractor/homeworld2.c trunk/extractor/nwn.c trunk/extractor/pak.c trunk/extractor/wad.c trunk/extractor/xtre.c Modified: trunk/extractor/bloodrayne.c =================================================================== --- trunk/extractor/bloodrayne.c 2008-03-08 20:11:07 UTC (rev 70) +++ trunk/extractor/bloodrayne.c 2008-03-08 21:12:54 UTC (rev 71) @@ -52,4 +52,5 @@ get_list, default_free_list, default_extract_file, + default_extract_mem, }; Modified: trunk/extractor/extractor.c =================================================================== --- trunk/extractor/extractor.c 2008-03-08 20:11:07 UTC (rev 70) +++ trunk/extractor/extractor.c 2008-03-08 21:12:54 UTC (rev 71) @@ -202,7 +202,6 @@ GtkTreeIter iter; GtkWidget *preview_win = data; file_t *file; - FILE *tmpf; int size; uint8_t *tmpdata; GdkPixbufLoader *pbl; @@ -214,15 +213,9 @@ if (!gtk_tree_model_get_iter(model, &iter, path)) return; gtk_tree_model_get(model, &iter, PTR_COL, &file, -1); - tmpf = tmpfile(); - cur_fmt->extract_file(input_file, file, tmpf); - fseek(tmpf, 0, SEEK_END); - size = ftell(tmpf); - if (size > MAX_IMG_SZ) size = MAX_IMG_SZ; - rewind(tmpf); - tmpdata = malloc(size); - fread(tmpdata, 1, size, tmpf); - fclose(tmpf); + tmpdata = malloc(MAX_IMG_SZ); + size = cur_fmt->extract_mem(input_file, file, tmpdata, MAX_IMG_SZ); + if (size > MAX_IMG_SZ || size < 0) size = MAX_IMG_SZ; pbl = gdk_pixbuf_loader_new(); gdk_pixbuf_loader_write(pbl, tmpdata, size, NULL); free(tmpdata); Modified: trunk/extractor/formats.h =================================================================== --- trunk/extractor/formats.h 2008-03-08 20:11:07 UTC (rev 70) +++ trunk/extractor/formats.h 2008-03-08 21:12:54 UTC (rev 71) @@ -22,6 +22,7 @@ file_t *(*get_list)(FILE *in); ///< get a list of files in archive void (*free_list)(file_t *list); ///< free file list obtained via get_list int (*extract_file)(FILE *in, const file_t *file, FILE *out); ///< extract a file + int (*extract_mem)(FILE *in, const file_t *file, uint8_t *out, int out_size); ///< extract a file to a buffer } fmt_desc_t; extern const fmt_desc_t bloodrayne_fmt; Modified: trunk/extractor/generic.c =================================================================== --- trunk/extractor/generic.c 2008-03-08 20:11:07 UTC (rev 70) +++ trunk/extractor/generic.c 2008-03-08 21:12:54 UTC (rev 71) @@ -197,4 +197,5 @@ get_list, default_free_ignorepriv, default_extract_file, + default_extract_mem, }; Modified: trunk/extractor/helpers.c =================================================================== --- trunk/extractor/helpers.c 2008-03-08 20:11:07 UTC (rev 70) +++ trunk/extractor/helpers.c 2008-03-08 21:12:54 UTC (rev 71) @@ -123,3 +123,16 @@ return fcopy(in, out, file->len); } +/** + * \brief default file-extract-to-memory function + * \param in archive file + * \param file description struct of file to extract + * \param out buffer to write data into + * \param size size of buffer + * \return number of bytes written to out + */ +int default_extract_mem(FILE *in, const file_t *file, uint8_t *out, int size) { + if (size > file->len) size = file->len; + fseek(in, file->start, SEEK_SET); + return fread(out, 1, size, in); +} Modified: trunk/extractor/helpers.h =================================================================== --- trunk/extractor/helpers.h 2008-03-08 20:11:07 UTC (rev 70) +++ trunk/extractor/helpers.h 2008-03-08 21:12:54 UTC (rev 71) @@ -13,4 +13,5 @@ void default_free_list(struct file_s *list); void default_free_ignorepriv(struct file_s *list); int default_extract_file(FILE *in, const struct file_s *file, FILE *out); +int default_extract_mem(FILE *in, const struct file_s *file, uint8_t *out, int size); #endif Modified: trunk/extractor/homeworld2.c =================================================================== --- trunk/extractor/homeworld2.c 2008-03-08 20:11:07 UTC (rev 70) +++ trunk/extractor/homeworld2.c 2008-03-08 21:12:54 UTC (rev 71) @@ -93,4 +93,5 @@ get_list, default_free_list, default_extract_file, + default_extract_mem, }; Modified: trunk/extractor/nwn.c =================================================================== --- trunk/extractor/nwn.c 2008-03-08 20:11:07 UTC (rev 70) +++ trunk/extractor/nwn.c 2008-03-08 21:12:54 UTC (rev 71) @@ -70,4 +70,5 @@ get_list, default_free_list, default_extract_file, + default_extract_mem, }; Modified: trunk/extractor/pak.c =================================================================== --- trunk/extractor/pak.c 2008-03-08 20:11:07 UTC (rev 70) +++ trunk/extractor/pak.c 2008-03-08 21:12:54 UTC (rev 71) @@ -48,4 +48,5 @@ get_list, default_free_list, default_extract_file, + default_extract_mem, }; Modified: trunk/extractor/wad.c =================================================================== --- trunk/extractor/wad.c 2008-03-08 20:11:07 UTC (rev 70) +++ trunk/extractor/wad.c 2008-03-08 21:12:54 UTC (rev 71) @@ -57,4 +57,5 @@ get_list, default_free_list, default_extract_file, + default_extract_mem, }; Modified: trunk/extractor/xtre.c =================================================================== --- trunk/extractor/xtre.c 2008-03-08 20:11:07 UTC (rev 70) +++ trunk/extractor/xtre.c 2008-03-08 21:12:54 UTC (rev 71) @@ -75,4 +75,5 @@ get_list, default_free_list, default_extract_file, + default_extract_mem, }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-03-08 20:11:10
|
Revision: 70 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=70&view=rev Author: someone-guy Date: 2008-03-08 12:11:07 -0800 (Sat, 08 Mar 2008) Log Message: ----------- Fix wrong type of SIZE_COL, this probably caused crashes on all 32 bit architectures Modified Paths: -------------- trunk/extractor/extractor.c Modified: trunk/extractor/extractor.c =================================================================== --- trunk/extractor/extractor.c 2008-03-05 20:28:53 UTC (rev 69) +++ trunk/extractor/extractor.c 2008-03-08 20:11:07 UTC (rev 70) @@ -48,7 +48,7 @@ //! types of columns in the file list table const int coltypes[] = { [FNAME_COL] = G_TYPE_STRING, - [SIZE_COL] = G_TYPE_INT, + [SIZE_COL] = G_TYPE_UINT64, [COMPR_COL] = G_TYPE_BOOLEAN, [PTR_COL] = G_TYPE_POINTER, }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-03-05 20:28:58
|
Revision: 69 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=69&view=rev Author: someone-guy Date: 2008-03-05 12:28:53 -0800 (Wed, 05 Mar 2008) Log Message: ----------- Add (slightly ugly) image preview code. Modified Paths: -------------- trunk/extractor/extractor.c Modified: trunk/extractor/extractor.c =================================================================== --- trunk/extractor/extractor.c 2008-03-05 20:28:46 UTC (rev 68) +++ trunk/extractor/extractor.c 2008-03-05 20:28:53 UTC (rev 69) @@ -191,9 +191,54 @@ return FALSE; } +#define MAX_IMG_SZ (100*1024*1024) + +/** + * Called when user double-clicks on a archive content + */ +static void row_activate(GtkTreeView *treeview, GtkTreePath *path, + GtkTreeViewColumn *col, gpointer data) { + GtkTreeModel *model = gtk_tree_view_get_model(treeview); + GtkTreeIter iter; + GtkWidget *preview_win = data; + file_t *file; + FILE *tmpf; + int size; + uint8_t *tmpdata; + GdkPixbufLoader *pbl; + GdkPixbuf *pb; + GtkWidget *img = gtk_bin_get_child(GTK_BIN(preview_win)); + if (img) + gtk_container_remove(GTK_CONTAINER(preview_win), img); + + if (!gtk_tree_model_get_iter(model, &iter, path)) + return; + gtk_tree_model_get(model, &iter, PTR_COL, &file, -1); + tmpf = tmpfile(); + cur_fmt->extract_file(input_file, file, tmpf); + fseek(tmpf, 0, SEEK_END); + size = ftell(tmpf); + if (size > MAX_IMG_SZ) size = MAX_IMG_SZ; + rewind(tmpf); + tmpdata = malloc(size); + fread(tmpdata, 1, size, tmpf); + fclose(tmpf); + pbl = gdk_pixbuf_loader_new(); + gdk_pixbuf_loader_write(pbl, tmpdata, size, NULL); + free(tmpdata); + gdk_pixbuf_loader_close(pbl, NULL); + pb = gdk_pixbuf_loader_get_pixbuf(pbl); + img = gtk_image_new_from_pixbuf(pb); + g_object_unref(pbl); + gtk_container_add(GTK_CONTAINER(preview_win), img); + gtk_widget_show(img); + gtk_window_present(GTK_WINDOW(preview_win)); +} + int main(int argc, char *argv[]) { int i; GtkWidget *window; + GtkWidget *preview_win; GtkWidget *table; GtkWidget *file_button; GtkWidget *button; @@ -208,6 +253,11 @@ gtk_disable_setlocale(); gtk_init(&argc, &argv); + preview_win = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_resizable(GTK_WINDOW(preview_win), FALSE); + g_signal_connect(G_OBJECT(preview_win), "delete_event", + G_CALLBACK(gtk_widget_hide_on_delete), NULL); + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), _("extractor")); g_signal_connect(G_OBJECT(window), "delete_event", @@ -242,6 +292,8 @@ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE); + g_signal_connect(G_OBJECT(treeview), "row-activated", + G_CALLBACK(row_activate), preview_win); gtk_container_add(GTK_CONTAINER(scrollwin), treeview); row++; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-03-05 20:28:47
|
Revision: 68 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=68&view=rev Author: someone-guy Date: 2008-03-05 12:28:46 -0800 (Wed, 05 Mar 2008) Log Message: ----------- Detect MSI files (no length detection yet, no idea how this could be done). Modified Paths: -------------- trunk/extractor/generic.c Modified: trunk/extractor/generic.c =================================================================== --- trunk/extractor/generic.c 2008-03-05 20:28:38 UTC (rev 67) +++ trunk/extractor/generic.c 2008-03-05 20:28:46 UTC (rev 68) @@ -51,6 +51,11 @@ int i; t = t << 8 | fgetc(in); switch (t) { + case HUGETAG(0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1): + add_entry(&list, cnt, "msi"); + list[cnt].start = ftell(in) - 8; + cnt++; + break; case HUGETAG(0x89, 'P', 'N', 'G', 0x0d, 0x0a, 0x1a, 0x0a): if (pngidx >= 0 && list[pngidx].len == 0) list[pngidx].len = ftell(in) - list[pngidx].start - 8; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-03-05 20:28:42
|
Revision: 67 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=67&view=rev Author: someone-guy Date: 2008-03-05 12:28:38 -0800 (Wed, 05 Mar 2008) Log Message: ----------- Distinguish between AVI/WAV/generic RIFF Modified Paths: -------------- trunk/extractor/generic.c Modified: trunk/extractor/generic.c =================================================================== --- trunk/extractor/generic.c 2008-02-26 17:17:51 UTC (rev 66) +++ trunk/extractor/generic.c 2008-03-05 20:28:38 UTC (rev 67) @@ -76,11 +76,14 @@ break; } case TAG('R', 'I', 'F', 'F'): { + const char *ext = "riff"; uint32_t len = read_le32(in); - uint32_t type = read_le32(in); + uint32_t type = read_be32(in); fseek(in, -8, SEEK_CUR); if (len <= 4 || !is_valid_fourcc(type)) break; - add_entry(&list, cnt, "riff"); + if (type == TAG('W', 'A', 'V', 'E')) ext = "wav"; + if (type >> 8 == TAG(0, 'A', 'V', 'I')) ext = "avi"; + add_entry(&list, cnt, ext); list[cnt].start = ftell(in) - 4; list[cnt].len = len + 8; cnt++; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-02-26 17:18:01
|
Revision: 66 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=66&view=rev Author: someone-guy Date: 2008-02-26 09:17:51 -0800 (Tue, 26 Feb 2008) Log Message: ----------- Add cab detection, make flash detection have less false positives Modified Paths: -------------- trunk/extractor/generic.c Modified: trunk/extractor/generic.c =================================================================== --- trunk/extractor/generic.c 2008-02-22 23:00:03 UTC (rev 65) +++ trunk/extractor/generic.c 2008-02-26 17:17:51 UTC (rev 66) @@ -65,6 +65,16 @@ break; } switch (t & 0xffffffff) { + case TAG('M', 'S', 'C', 'F'): { + uint32_t unk = read_le32(in); + uint32_t size = read_le32(in); + fseek(in, -8, SEEK_CUR); + add_entry(&list, cnt, "cab"); + list[cnt].start = ftell(in) - 4; + list[cnt].len = size; + cnt++; + break; + } case TAG('R', 'I', 'F', 'F'): { uint32_t len = read_le32(in); uint32_t type = read_le32(in); @@ -97,14 +107,19 @@ case TAG(0, 'F', 'W', 'S'): // compressed flash. Note that length is _decompressed_ size // so we will extract more data than necessary - case TAG(0, 'C', 'W', 'S'): + case TAG(0, 'C', 'W', 'S'): { + uint8_t ver = fgetc(in); + uint32_t size = read_le32(in); + uint8_t rectbits = fgetc(in) >> 3; + fseek(in, -6, SEEK_CUR); + if ((ver & 0xf0) || rectbits != 15) + break; add_entry(&list, cnt, "swf"); list[cnt].start = ftell(in) - 3; - fgetc(in); - list[cnt].len = read_le32(in); - fseek(in, -5, SEEK_CUR); + list[cnt].len = size; cnt++; break; + } case TAG(0, 'B', 'Z', 'h'): if (bz2idx >= 0 && list[bz2idx].len == 0) { list[bz2idx].start = ftell(in) - 3; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-02-22 23:00:06
|
Revision: 65 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=65&view=rev Author: someone-guy Date: 2008-02-22 15:00:03 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Add some useful warnings, use -O2 Modified Paths: -------------- trunk/extractor/Makefile Modified: trunk/extractor/Makefile =================================================================== --- trunk/extractor/Makefile 2008-02-22 22:59:54 UTC (rev 64) +++ trunk/extractor/Makefile 2008-02-22 23:00:03 UTC (rev 65) @@ -1,5 +1,5 @@ CC=gcc -CFLAGS=-Wall -g -O +CFLAGS=-Wall -Wdeclaration-after-statement -Wpointer-arith -Wredundant-decls -Wcast-qual -Wwrite-strings -g -O2 MODULES= \ bloodrayne.c \ generic.c \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-02-22 22:59:56
|
Revision: 64 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=64&view=rev Author: someone-guy Date: 2008-02-22 14:59:54 -0800 (Fri, 22 Feb 2008) Log Message: ----------- More missing const Modified Paths: -------------- trunk/extractor/generic.c trunk/extractor/xtre.c Modified: trunk/extractor/generic.c =================================================================== --- trunk/extractor/generic.c 2008-02-22 22:34:11 UTC (rev 63) +++ trunk/extractor/generic.c 2008-02-22 22:59:54 UTC (rev 64) @@ -17,7 +17,7 @@ return 0; } -static void add_entry(file_t **list, int cnt, char *ext) { +static void add_entry(file_t **list, int cnt, const char *ext) { file_t *l = *list; l = realloc(l, (cnt + 2) * sizeof(file_t)); memset(&l[cnt + 1], 0, sizeof(file_t)); Modified: trunk/extractor/xtre.c =================================================================== --- trunk/extractor/xtre.c 2008-02-22 22:34:11 UTC (rev 63) +++ trunk/extractor/xtre.c 2008-02-22 22:59:54 UTC (rev 64) @@ -34,7 +34,7 @@ list = calloc(count + 1, sizeof(file_t)); for (i = 0; i < count; i++) { uint32_t sig; - char *formatstr; + const char *formatstr; fseek(in, tblpos + 8 * i, SEEK_SET); list[i].start = read_le32(in); list[i].len = read_le32(in); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-02-22 22:34:15
|
Revision: 63 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=63&view=rev Author: someone-guy Date: 2008-02-22 14:34:11 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Format auto-detection for file given on command-line Modified Paths: -------------- trunk/extractor/extractor.c Modified: trunk/extractor/extractor.c =================================================================== --- trunk/extractor/extractor.c 2008-02-22 22:18:20 UTC (rev 62) +++ trunk/extractor/extractor.c 2008-02-22 22:34:11 UTC (rev 63) @@ -119,13 +119,11 @@ } static int open_file(const char *fname, const fmt_desc_t *fmt) { - if (!fmt) - fmt = &generic_fmt; // close previous file and free its data if (cur_fmt && flist) cur_fmt->free_list(flist); flist = NULL; - cur_fmt = fmt; + cur_fmt = NULL; if (input_file) fclose(input_file); @@ -133,6 +131,18 @@ input_file = fopen(fname, "rb"); if (!input_file) return 0; + if (!fmt) { + int i; + for (i = 0; fmts[i]; i++) { + if (fmts[i]->check_file && fmts[i]->check_file(input_file)) { + fmt = fmts[i]; + break; + } + } + } + if (!fmt) + fmt = &generic_fmt; + cur_fmt = fmt; flist = cur_fmt->get_list(input_file); set_treeview(flist); return 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-02-22 22:18:22
|
Revision: 62 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=62&view=rev Author: someone-guy Date: 2008-02-22 14:18:20 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Sort alphabetically Modified Paths: -------------- trunk/extractor/Makefile trunk/extractor/extractor.c trunk/extractor/formats.h Modified: trunk/extractor/Makefile =================================================================== --- trunk/extractor/Makefile 2008-02-22 22:14:58 UTC (rev 61) +++ trunk/extractor/Makefile 2008-02-22 22:18:20 UTC (rev 62) @@ -1,12 +1,13 @@ CC=gcc CFLAGS=-Wall -g -O -MODULES=nwn.c \ - homeworld2.c \ - bloodrayne.c \ - xtre.c \ - wad.c \ - pak.c \ - generic.c \ +MODULES= \ + bloodrayne.c \ + generic.c \ + homeworld2.c \ + nwn.c \ + pak.c \ + wad.c \ + xtre.c \ all: extractor Modified: trunk/extractor/extractor.c =================================================================== --- trunk/extractor/extractor.c 2008-02-22 22:14:58 UTC (rev 61) +++ trunk/extractor/extractor.c 2008-02-22 22:18:20 UTC (rev 62) @@ -18,13 +18,13 @@ //! brief NULL-terminated array of supported formats const fmt_desc_t * const fmts[] = { + &bloodrayne_fmt, + &generic_fmt, + &homeworld2_fmt, &nwn_fmt, - &homeworld2_fmt, - &bloodrayne_fmt, + &pak_fmt, + &wad_fmt, &xtre_fmt, - &wad_fmt, - &pak_fmt, - &generic_fmt, NULL }; Modified: trunk/extractor/formats.h =================================================================== --- trunk/extractor/formats.h 2008-02-22 22:14:58 UTC (rev 61) +++ trunk/extractor/formats.h 2008-02-22 22:18:20 UTC (rev 62) @@ -24,12 +24,12 @@ int (*extract_file)(FILE *in, const file_t *file, FILE *out); ///< extract a file } fmt_desc_t; +extern const fmt_desc_t bloodrayne_fmt; +extern const fmt_desc_t generic_fmt; +extern const fmt_desc_t homeworld2_fmt; extern const fmt_desc_t nwn_fmt; -extern const fmt_desc_t homeworld2_fmt; -extern const fmt_desc_t bloodrayne_fmt; +extern const fmt_desc_t pak_fmt; +extern const fmt_desc_t wad_fmt; extern const fmt_desc_t xtre_fmt; -extern const fmt_desc_t wad_fmt; -extern const fmt_desc_t pak_fmt; -extern const fmt_desc_t generic_fmt; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-02-22 22:15:00
|
Revision: 61 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=61&view=rev Author: someone-guy Date: 2008-02-22 14:14:58 -0800 (Fri, 22 Feb 2008) Log Message: ----------- extract_file has no reason to modify file_t, so make the argument const. Modified Paths: -------------- trunk/extractor/formats.h trunk/extractor/helpers.c trunk/extractor/helpers.h Modified: trunk/extractor/formats.h =================================================================== --- trunk/extractor/formats.h 2008-02-22 22:14:43 UTC (rev 60) +++ trunk/extractor/formats.h 2008-02-22 22:14:58 UTC (rev 61) @@ -21,7 +21,7 @@ int (*check_file)(FILE *in); ///< check function for format autodetection file_t *(*get_list)(FILE *in); ///< get a list of files in archive void (*free_list)(file_t *list); ///< free file list obtained via get_list - int (*extract_file)(FILE *in, file_t *file, FILE *out); ///< extract a file + int (*extract_file)(FILE *in, const file_t *file, FILE *out); ///< extract a file } fmt_desc_t; extern const fmt_desc_t nwn_fmt; Modified: trunk/extractor/helpers.c =================================================================== --- trunk/extractor/helpers.c 2008-02-22 22:14:43 UTC (rev 60) +++ trunk/extractor/helpers.c 2008-02-22 22:14:58 UTC (rev 61) @@ -118,7 +118,7 @@ * \param out file to write data into * \return number of bytes written to out */ -int default_extract_file(FILE *in, file_t *file, FILE *out) { +int default_extract_file(FILE *in, const file_t *file, FILE *out) { fseek(in, file->start, SEEK_SET); return fcopy(in, out, file->len); } Modified: trunk/extractor/helpers.h =================================================================== --- trunk/extractor/helpers.h 2008-02-22 22:14:43 UTC (rev 60) +++ trunk/extractor/helpers.h 2008-02-22 22:14:58 UTC (rev 61) @@ -12,5 +12,5 @@ struct file_s; void default_free_list(struct file_s *list); void default_free_ignorepriv(struct file_s *list); -int default_extract_file(FILE *in, struct file_s *file, FILE *out); +int default_extract_file(FILE *in, const struct file_s *file, FILE *out); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-02-22 22:14:46
|
Revision: 60 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=60&view=rev Author: someone-guy Date: 2008-02-22 14:14:43 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Add maximum size for C string read from file Modified Paths: -------------- trunk/extractor/helpers.c Modified: trunk/extractor/helpers.c =================================================================== --- trunk/extractor/helpers.c 2008-02-22 22:14:31 UTC (rev 59) +++ trunk/extractor/helpers.c 2008-02-22 22:14:43 UTC (rev 60) @@ -12,6 +12,7 @@ #include "formats.h" #define DEF_CSTR_SIZE 32 +#define MAX_CSTR_SIZE 1024 /** * \brief read a C string (0-terminated) from a file * \param f file to read from, starting at current position @@ -21,6 +22,7 @@ char *name = malloc(DEF_CSTR_SIZE); int size = DEF_CSTR_SIZE, used = 0; while ((name[used++] = fgetc(f))) { + if (used == MAX_CSTR_SIZE) break; if (used == size) { size *= 2; name = realloc(name, size); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-02-22 22:14:34
|
Revision: 59 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=59&view=rev Author: someone-guy Date: 2008-02-22 14:14:31 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Get rid of useless () Modified Paths: -------------- trunk/extractor/bloodrayne.c trunk/extractor/homeworld2.c trunk/extractor/nwn.c trunk/extractor/xtre.c Modified: trunk/extractor/bloodrayne.c =================================================================== --- trunk/extractor/bloodrayne.c 2008-02-22 22:05:39 UTC (rev 58) +++ trunk/extractor/bloodrayne.c 2008-02-22 22:14:31 UTC (rev 59) @@ -18,7 +18,7 @@ char sig[5] = {0}; rewind(in); fread(sig, 4, 1, in); - return (strcmp(sig, "POD3") == 0); + return strcmp(sig, "POD3") == 0; } static file_t *get_list(FILE *in) { Modified: trunk/extractor/homeworld2.c =================================================================== --- trunk/extractor/homeworld2.c 2008-02-22 22:05:39 UTC (rev 58) +++ trunk/extractor/homeworld2.c 2008-02-22 22:14:31 UTC (rev 59) @@ -18,7 +18,7 @@ char sig[9] = {0}; rewind(in); fread(sig, 8, 1, in); - return (strcmp(sig, "_ARCHIVE") == 0); + return strcmp(sig, "_ARCHIVE") == 0; } static file_t *get_list(FILE *in) { Modified: trunk/extractor/nwn.c =================================================================== --- trunk/extractor/nwn.c 2008-02-22 22:05:39 UTC (rev 58) +++ trunk/extractor/nwn.c 2008-02-22 22:14:31 UTC (rev 59) @@ -18,7 +18,7 @@ char sig[9] = {0}; rewind(in); fread(sig, 8, 1, in); - return (strcmp(sig, "MOD V1.0") == 0); + return strcmp(sig, "MOD V1.0") == 0; } static file_t *get_list(FILE *in) { Modified: trunk/extractor/xtre.c =================================================================== --- trunk/extractor/xtre.c 2008-02-22 22:05:39 UTC (rev 58) +++ trunk/extractor/xtre.c 2008-02-22 22:14:31 UTC (rev 59) @@ -18,7 +18,7 @@ char sig[5] = {0}; rewind(in); fread(sig, 4, 1, in); - return (strcmp(sig, "XTRE") == 0); + return strcmp(sig, "XTRE") == 0; } static file_t *get_list(FILE *in) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-02-22 22:05:45
|
Revision: 58 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=58&view=rev Author: someone-guy Date: 2008-02-22 14:05:39 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Replace '/' in file names by '_' Modified Paths: -------------- trunk/extractor/extractor.c Modified: trunk/extractor/extractor.c =================================================================== --- trunk/extractor/extractor.c 2008-02-22 22:00:04 UTC (rev 57) +++ trunk/extractor/extractor.c 2008-02-22 22:05:39 UTC (rev 58) @@ -69,6 +69,7 @@ static void extract_foreach(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) { char *fname; + char *good_slash, *slash; file_t *file; FILE *out; gtk_tree_model_get(model, iter, PTR_COL, &file, -1); @@ -76,6 +77,9 @@ strcpy(fname, data); strcat(fname, "/"); strcat(fname, file->name); + good_slash = fname + strlen(data); + while ((slash = strrchr(fname, '/')) > good_slash) + *slash = '_'; out = fopen(fname, "wb"); if (out) cur_fmt->extract_file(input_file, file, out); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-02-22 22:00:07
|
Revision: 57 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=57&view=rev Author: someone-guy Date: 2008-02-22 14:00:04 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Avoid a crash if we could not open an output file Modified Paths: -------------- trunk/extractor/extractor.c Modified: trunk/extractor/extractor.c =================================================================== --- trunk/extractor/extractor.c 2008-02-22 21:59:06 UTC (rev 56) +++ trunk/extractor/extractor.c 2008-02-22 22:00:04 UTC (rev 57) @@ -77,7 +77,8 @@ strcat(fname, "/"); strcat(fname, file->name); out = fopen(fname, "wb"); - cur_fmt->extract_file(input_file, file, out); + if (out) + cur_fmt->extract_file(input_file, file, out); fclose(out); free(fname); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-02-22 21:59:10
|
Revision: 56 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=56&view=rev Author: someone-guy Date: 2008-02-22 13:59:06 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Add HalfLife PAK format Modified Paths: -------------- trunk/extractor/Makefile trunk/extractor/extractor.c trunk/extractor/formats.h Added Paths: ----------- trunk/extractor/pak.c Modified: trunk/extractor/Makefile =================================================================== --- trunk/extractor/Makefile 2008-02-19 21:22:54 UTC (rev 55) +++ trunk/extractor/Makefile 2008-02-22 21:59:06 UTC (rev 56) @@ -5,6 +5,7 @@ bloodrayne.c \ xtre.c \ wad.c \ + pak.c \ generic.c \ all: extractor Modified: trunk/extractor/extractor.c =================================================================== --- trunk/extractor/extractor.c 2008-02-19 21:22:54 UTC (rev 55) +++ trunk/extractor/extractor.c 2008-02-22 21:59:06 UTC (rev 56) @@ -23,6 +23,7 @@ &bloodrayne_fmt, &xtre_fmt, &wad_fmt, + &pak_fmt, &generic_fmt, NULL }; Modified: trunk/extractor/formats.h =================================================================== --- trunk/extractor/formats.h 2008-02-19 21:22:54 UTC (rev 55) +++ trunk/extractor/formats.h 2008-02-22 21:59:06 UTC (rev 56) @@ -29,6 +29,7 @@ extern const fmt_desc_t bloodrayne_fmt; extern const fmt_desc_t xtre_fmt; extern const fmt_desc_t wad_fmt; +extern const fmt_desc_t pak_fmt; extern const fmt_desc_t generic_fmt; #endif Added: trunk/extractor/pak.c =================================================================== --- trunk/extractor/pak.c (rev 0) +++ trunk/extractor/pak.c 2008-02-22 21:59:06 UTC (rev 56) @@ -0,0 +1,51 @@ +/** + * \file wad.c + * \brief routines for handling the HalfLife PAK archive files + * + * Copyright (C) 2008 Reimar Döffinger + * License: GPL v2 (see LICENSE file) + */ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <inttypes.h> +#include "formats.h" +#include "helpers.h" + +//! check if this is a PAK archive file (starts with PACK) +static int check_file(FILE *in) { + char sig[5] = {0}; + rewind(in); + fread(sig, 4, 1, in); + return strcmp(sig, "PACK") == 0; +} + +static file_t *get_list(FILE *in) { + file_t *list; + uint32_t count, tblpos; + int i; + rewind(in); + fseek(in, 4, SEEK_SET); + tblpos = read_le32(in); + count = read_le32(in) / 64; + if (count > MAX_FILES) count = MAX_FILES; + list = calloc(count + 1, sizeof(file_t)); + for (i = 0; i < count; i++) { + fseek(in, tblpos + 64 * i, SEEK_SET); + list[i].name = calloc(1, 57); + fread(list[i].name, 1, 56, in); + list[i].start = read_le32(in); + list[i].len = read_le32(in); + } + return list; +} + +const fmt_desc_t pak_fmt = { + "PAK (HalfLife)", + "PAK (*.pak)", + "*.pak;*.PAK", + check_file, + get_list, + default_free_list, + default_extract_file, +}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-02-19 21:22:58
|
Revision: 55 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=55&view=rev Author: someone-guy Date: 2008-02-19 13:22:54 -0800 (Tue, 19 Feb 2008) Log Message: ----------- Lots of missing const Modified Paths: -------------- trunk/extractor/bloodrayne.c trunk/extractor/extractor.c trunk/extractor/formats.h trunk/extractor/generic.c trunk/extractor/homeworld2.c trunk/extractor/nwn.c trunk/extractor/wad.c trunk/extractor/xtre.c Modified: trunk/extractor/bloodrayne.c =================================================================== --- trunk/extractor/bloodrayne.c 2008-02-19 21:12:31 UTC (rev 54) +++ trunk/extractor/bloodrayne.c 2008-02-19 21:22:54 UTC (rev 55) @@ -44,7 +44,7 @@ return list; } -fmt_desc_t bloodrayne_fmt = { +const fmt_desc_t bloodrayne_fmt = { "BloodRayne", "BloodRayne (*.pod)", "*.pod;*.POD", Modified: trunk/extractor/extractor.c =================================================================== --- trunk/extractor/extractor.c 2008-02-19 21:12:31 UTC (rev 54) +++ trunk/extractor/extractor.c 2008-02-19 21:22:54 UTC (rev 55) @@ -17,7 +17,7 @@ #include "formats.h" //! brief NULL-terminated array of supported formats -fmt_desc_t *fmts[] = { +const fmt_desc_t * const fmts[] = { &nwn_fmt, &homeworld2_fmt, &bloodrayne_fmt, @@ -45,7 +45,7 @@ }; //! types of columns in the file list table -int coltypes[] = { +const int coltypes[] = { [FNAME_COL] = G_TYPE_STRING, [SIZE_COL] = G_TYPE_INT, [COMPR_COL] = G_TYPE_BOOLEAN, @@ -57,7 +57,7 @@ GtkTreeSelection *selection; FILE *input_file = NULL; file_t *flist = NULL; -fmt_desc_t *cur_fmt = NULL; +const fmt_desc_t *cur_fmt = NULL; /** * \brief extracts the file specified by iter @@ -112,7 +112,7 @@ } } -static int open_file(char *fname, fmt_desc_t *fmt) { +static int open_file(const char *fname, const fmt_desc_t *fmt) { if (!fmt) fmt = &generic_fmt; // close previous file and free its data @@ -139,7 +139,7 @@ const char *filter = gtk_file_filter_get_name(gtk_file_chooser_get_filter( GTK_FILE_CHOOSER(widget))); - fmt_desc_t **fmt = fmts; + const fmt_desc_t * const *fmt = fmts; gchar *fname = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)); while ((*fmt)->desc && strcmp(filter, _((*fmt)->desc)) != 0) fmt++; if (!(*fmt)->desc) { Modified: trunk/extractor/formats.h =================================================================== --- trunk/extractor/formats.h 2008-02-19 21:12:31 UTC (rev 54) +++ trunk/extractor/formats.h 2008-02-19 21:22:54 UTC (rev 55) @@ -24,11 +24,11 @@ int (*extract_file)(FILE *in, file_t *file, FILE *out); ///< extract a file } fmt_desc_t; -extern fmt_desc_t nwn_fmt; -extern fmt_desc_t homeworld2_fmt; -extern fmt_desc_t bloodrayne_fmt; -extern fmt_desc_t xtre_fmt; -extern fmt_desc_t wad_fmt; -extern fmt_desc_t generic_fmt; +extern const fmt_desc_t nwn_fmt; +extern const fmt_desc_t homeworld2_fmt; +extern const fmt_desc_t bloodrayne_fmt; +extern const fmt_desc_t xtre_fmt; +extern const fmt_desc_t wad_fmt; +extern const fmt_desc_t generic_fmt; #endif Modified: trunk/extractor/generic.c =================================================================== --- trunk/extractor/generic.c 2008-02-19 21:12:31 UTC (rev 54) +++ trunk/extractor/generic.c 2008-02-19 21:22:54 UTC (rev 55) @@ -166,7 +166,7 @@ return list; } -fmt_desc_t generic_fmt = { +const fmt_desc_t generic_fmt = { "Generic File", "Generic File", "*", Modified: trunk/extractor/homeworld2.c =================================================================== --- trunk/extractor/homeworld2.c 2008-02-19 21:12:31 UTC (rev 54) +++ trunk/extractor/homeworld2.c 2008-02-19 21:22:54 UTC (rev 55) @@ -85,7 +85,7 @@ return list; } -fmt_desc_t homeworld2_fmt = { +const fmt_desc_t homeworld2_fmt = { "Homeworld 2", "Homeworld 2 (*.big)", "*.big", Modified: trunk/extractor/nwn.c =================================================================== --- trunk/extractor/nwn.c 2008-02-19 21:12:31 UTC (rev 54) +++ trunk/extractor/nwn.c 2008-02-19 21:22:54 UTC (rev 55) @@ -62,7 +62,7 @@ return list; } -fmt_desc_t nwn_fmt = { +const fmt_desc_t nwn_fmt = { "Neverwinter Nights", "Neverwinter Nights (*.mod;*.nwm;*.sav)", "*.mod;*.nwm;*.sav", Modified: trunk/extractor/wad.c =================================================================== --- trunk/extractor/wad.c 2008-02-19 21:12:31 UTC (rev 54) +++ trunk/extractor/wad.c 2008-02-19 21:22:54 UTC (rev 55) @@ -49,7 +49,7 @@ return list; } -fmt_desc_t wad_fmt = { +const fmt_desc_t wad_fmt = { "WAD (Doom etc.)", "WAD (*.wad)", "*.wad;*.WAD", Modified: trunk/extractor/xtre.c =================================================================== --- trunk/extractor/xtre.c 2008-02-19 21:12:31 UTC (rev 54) +++ trunk/extractor/xtre.c 2008-02-19 21:22:54 UTC (rev 55) @@ -67,7 +67,7 @@ return list; } -fmt_desc_t xtre_fmt = { +const fmt_desc_t xtre_fmt = { "Wing Commander IV", "Wing Commander IV (*.tre)", "*.tre", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-02-19 21:12:33
|
Revision: 54 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=54&view=rev Author: someone-guy Date: 2008-02-19 13:12:31 -0800 (Tue, 19 Feb 2008) Log Message: ----------- Add wad support Modified Paths: -------------- trunk/extractor/Makefile trunk/extractor/extractor.c trunk/extractor/formats.h Added Paths: ----------- trunk/extractor/wad.c Modified: trunk/extractor/Makefile =================================================================== --- trunk/extractor/Makefile 2008-02-19 20:54:36 UTC (rev 53) +++ trunk/extractor/Makefile 2008-02-19 21:12:31 UTC (rev 54) @@ -4,6 +4,7 @@ homeworld2.c \ bloodrayne.c \ xtre.c \ + wad.c \ generic.c \ all: extractor Modified: trunk/extractor/extractor.c =================================================================== --- trunk/extractor/extractor.c 2008-02-19 20:54:36 UTC (rev 53) +++ trunk/extractor/extractor.c 2008-02-19 21:12:31 UTC (rev 54) @@ -22,6 +22,7 @@ &homeworld2_fmt, &bloodrayne_fmt, &xtre_fmt, + &wad_fmt, &generic_fmt, NULL }; Modified: trunk/extractor/formats.h =================================================================== --- trunk/extractor/formats.h 2008-02-19 20:54:36 UTC (rev 53) +++ trunk/extractor/formats.h 2008-02-19 21:12:31 UTC (rev 54) @@ -28,6 +28,7 @@ extern fmt_desc_t homeworld2_fmt; extern fmt_desc_t bloodrayne_fmt; extern fmt_desc_t xtre_fmt; +extern fmt_desc_t wad_fmt; extern fmt_desc_t generic_fmt; #endif Added: trunk/extractor/wad.c =================================================================== --- trunk/extractor/wad.c (rev 0) +++ trunk/extractor/wad.c 2008-02-19 21:12:31 UTC (rev 54) @@ -0,0 +1,60 @@ +/** + * \file wad.c + * \brief routines for handling the Doom etc. WAD archive files + * + * Copyright (C) 2008 Reimar Döffinger + * License: GPL v2 (see LICENSE file) + */ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <inttypes.h> +#include "formats.h" +#include "helpers.h" + +//! check if this is a WAD archive file (starts with IWAD, PWAD, WAD3) +static int check_file(FILE *in) { + char sig[5] = {0}; + rewind(in); + fread(sig, 4, 1, in); + return strcmp(sig, "IWAD") == 0 || strcmp(sig, "PWAD") == 0 || strcmp(sig, "WAD3") == 0; +} + +static file_t *get_list(FILE *in) { + char sig[5] = {0}; + file_t *list; + uint32_t count, tblpos; + int i; + int v3; + rewind(in); + fread(sig, 4, 1, in); + v3 = strcmp(sig, "WAD3") == 0; + count = read_le32(in); + if (count > MAX_FILES) count = MAX_FILES; + tblpos = read_le32(in); + list = calloc(count + 1, sizeof(file_t)); + for (i = 0; i < count; i++) { + fseek(in, tblpos + (v3 ? 32 : 16) * i, SEEK_SET); + list[i].start = read_le32(in); + list[i].len = read_le32(in); + if (v3) { + int size2 = read_le32(in); + // should always be equal... + if (size2 > list[i].len) list[i].len = size2; + read_le32(in); // unknown + } + list[i].name = calloc(1, 17); + fread(list[i].name, 1, v3 ? 16 : 8, in); + } + return list; +} + +fmt_desc_t wad_fmt = { + "WAD (Doom etc.)", + "WAD (*.wad)", + "*.wad;*.WAD", + check_file, + get_list, + default_free_list, + default_extract_file, +}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-02-19 20:54:40
|
Revision: 53 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=53&view=rev Author: someone-guy Date: 2008-02-19 12:54:36 -0800 (Tue, 19 Feb 2008) Log Message: ----------- Properly limit number of listed files Modified Paths: -------------- trunk/extractor/bloodrayne.c trunk/extractor/formats.h trunk/extractor/generic.c trunk/extractor/homeworld2.c trunk/extractor/nwn.c trunk/extractor/xtre.c Modified: trunk/extractor/bloodrayne.c =================================================================== --- trunk/extractor/bloodrayne.c 2008-02-19 20:42:38 UTC (rev 52) +++ trunk/extractor/bloodrayne.c 2008-02-19 20:54:36 UTC (rev 53) @@ -27,6 +27,7 @@ int i; fseek(in, 0x58, SEEK_SET); count = read_le32(in); + if (count > MAX_FILES) count = MAX_FILES; fseek(in, 0x108, SEEK_SET); tblpos = read_le32(in); namepos = tblpos + 20 * count; Modified: trunk/extractor/formats.h =================================================================== --- trunk/extractor/formats.h 2008-02-19 20:42:38 UTC (rev 52) +++ trunk/extractor/formats.h 2008-02-19 20:54:36 UTC (rev 53) @@ -1,5 +1,8 @@ #ifndef FORMATS_H #define FORMATS_H + +#define MAX_FILES 100000 + //! struct describing a file in the archive typedef struct file_s { char *name; ///< filename Modified: trunk/extractor/generic.c =================================================================== --- trunk/extractor/generic.c 2008-02-19 20:42:38 UTC (rev 52) +++ trunk/extractor/generic.c 2008-02-19 20:54:36 UTC (rev 53) @@ -47,7 +47,7 @@ int cnt = 0; file_t *list = calloc(1, sizeof(file_t)); rewind(in); - while (!feof(in) && cnt + 3 < SIZE_MAX / sizeof(file_t)) { + while (!feof(in) && cnt < MAX_FILES) { int i; t = t << 8 | fgetc(in); switch (t) { Modified: trunk/extractor/homeworld2.c =================================================================== --- trunk/extractor/homeworld2.c 2008-02-19 20:42:38 UTC (rev 52) +++ trunk/extractor/homeworld2.c 2008-02-19 20:54:36 UTC (rev 53) @@ -37,6 +37,7 @@ pathcount = read_le16(in); // number of paths tblpos = read_le32(in) + 0xb4; count = read_le16(in); + if (count > MAX_FILES) count = MAX_FILES; namepos = read_le32(in) + 0xb4; pathmap = calloc(count, sizeof(char *)); paths = calloc(pathcount, sizeof(char *)); Modified: trunk/extractor/nwn.c =================================================================== --- trunk/extractor/nwn.c 2008-02-19 20:42:38 UTC (rev 52) +++ trunk/extractor/nwn.c 2008-02-19 20:54:36 UTC (rev 53) @@ -27,6 +27,7 @@ int i; fseek(in, 0x10, SEEK_SET); count = read_le32(in); + if (count > MAX_FILES) count = MAX_FILES; read_le32(in); // offset for module description namepos = read_le32(in); tblpos = read_le32(in); Modified: trunk/extractor/xtre.c =================================================================== --- trunk/extractor/xtre.c 2008-02-19 20:42:38 UTC (rev 52) +++ trunk/extractor/xtre.c 2008-02-19 20:54:36 UTC (rev 53) @@ -30,6 +30,7 @@ tblend = read_le32(in); if (tblend < tblpos) count = 0; else count = (tblend - tblpos) / 8; + if (count > MAX_FILES) count = MAX_FILES; list = calloc(count + 1, sizeof(file_t)); for (i = 0; i < count; i++) { uint32_t sig; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-02-19 20:42:43
|
Revision: 52 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=52&view=rev Author: someone-guy Date: 2008-02-19 12:42:38 -0800 (Tue, 19 Feb 2008) Log Message: ----------- Do not use system-reserved names for header inclusion guards Modified Paths: -------------- trunk/extractor/formats.h trunk/extractor/helpers.h Modified: trunk/extractor/formats.h =================================================================== --- trunk/extractor/formats.h 2008-02-19 20:08:53 UTC (rev 51) +++ trunk/extractor/formats.h 2008-02-19 20:42:38 UTC (rev 52) @@ -1,5 +1,5 @@ -#ifndef _FORMATS_H -#define _FORMATS_H +#ifndef FORMATS_H +#define FORMATS_H //! struct describing a file in the archive typedef struct file_s { char *name; ///< filename Modified: trunk/extractor/helpers.h =================================================================== --- trunk/extractor/helpers.h 2008-02-19 20:08:53 UTC (rev 51) +++ trunk/extractor/helpers.h 2008-02-19 20:42:38 UTC (rev 52) @@ -1,5 +1,5 @@ -#ifndef _HELPERS_H -#define _HELPERS_H +#ifndef HELPERS_H +#define HELPERS_H char *read_cstring(FILE *f); uint16_t read_le16(FILE *f); uint32_t read_le32(FILE *f); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-02-19 20:08:55
|
Revision: 51 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=51&view=rev Author: someone-guy Date: 2008-02-19 12:08:53 -0800 (Tue, 19 Feb 2008) Log Message: ----------- Try harder to allow to extract PNG files Modified Paths: -------------- trunk/extractor/generic.c Modified: trunk/extractor/generic.c =================================================================== --- trunk/extractor/generic.c 2008-02-19 20:08:46 UTC (rev 50) +++ trunk/extractor/generic.c 2008-02-19 20:08:53 UTC (rev 51) @@ -52,10 +52,8 @@ t = t << 8 | fgetc(in); switch (t) { case HUGETAG(0x89, 'P', 'N', 'G', 0x0d, 0x0a, 0x1a, 0x0a): - if (pngidx >= 0 && list[pngidx].len == 0) { - list[pngidx].start = ftell(in) - 8; - break; - } + if (pngidx >= 0 && list[pngidx].len == 0) + list[pngidx].len = ftell(in) - list[pngidx].start - 8; add_entry(&list, cnt, "png"); list[cnt].start = ftell(in) - 8; pngidx = cnt; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <som...@us...> - 2008-02-19 20:08:53
|
Revision: 50 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=50&view=rev Author: someone-guy Date: 2008-02-19 12:08:46 -0800 (Tue, 19 Feb 2008) Log Message: ----------- Fix use of wrong index Modified Paths: -------------- trunk/extractor/generic.c Modified: trunk/extractor/generic.c =================================================================== --- trunk/extractor/generic.c 2008-02-19 20:08:39 UTC (rev 49) +++ trunk/extractor/generic.c 2008-02-19 20:08:46 UTC (rev 50) @@ -157,7 +157,7 @@ for (i = 0; i < 8; i++) { if ((t & mask) == endmark) { // end marker plus space for CRC - list[bz2idx].len = ftell(in) - list[i].start + 4; + list[bz2idx].len = ftell(in) - list[bz2idx].start + 4; break; } endmark <<= 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |