[Extractor-gtk-cvslog] SF.net SVN: extractor-gtk:[104] trunk/extractor
Extract files from unusual archive formats
Brought to you by:
someone-guy
|
From: <som...@us...> - 2008-08-22 16:11:28
|
Revision: 104
http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=104&view=rev
Author: someone-guy
Date: 2008-08-22 16:11:25 +0000 (Fri, 22 Aug 2008)
Log Message:
-----------
Module to extract character images from MetalGear Solid: TS subtitles
Modified Paths:
--------------
trunk/extractor/Makefile
trunk/extractor/extractor.c
trunk/extractor/formats.h
trunk/extractor/helpers.c
trunk/extractor/helpers.h
Added Paths:
-----------
trunk/extractor/solidsub.c
Modified: trunk/extractor/Makefile
===================================================================
--- trunk/extractor/Makefile 2008-08-22 16:10:43 UTC (rev 103)
+++ trunk/extractor/Makefile 2008-08-22 16:11:25 UTC (rev 104)
@@ -8,6 +8,7 @@
nwn.c \
pak.c \
solid.c \
+ solidsub.c \
wad.c \
xtre.c \
Modified: trunk/extractor/extractor.c
===================================================================
--- trunk/extractor/extractor.c 2008-08-22 16:10:43 UTC (rev 103)
+++ trunk/extractor/extractor.c 2008-08-22 16:11:25 UTC (rev 104)
@@ -24,6 +24,7 @@
&nwn_fmt,
&pak_fmt,
&solid_fmt,
+ &solidsub_fmt,
&wad_fmt,
&xtre_fmt,
NULL
Modified: trunk/extractor/formats.h
===================================================================
--- trunk/extractor/formats.h 2008-08-22 16:10:43 UTC (rev 103)
+++ trunk/extractor/formats.h 2008-08-22 16:11:25 UTC (rev 104)
@@ -32,6 +32,7 @@
extern const fmt_desc_t nwn_fmt;
extern const fmt_desc_t pak_fmt;
extern const fmt_desc_t solid_fmt;
+extern const fmt_desc_t solidsub_fmt;
extern const fmt_desc_t wad_fmt;
extern const fmt_desc_t xtre_fmt;
Modified: trunk/extractor/helpers.c
===================================================================
--- trunk/extractor/helpers.c 2008-08-22 16:10:43 UTC (rev 103)
+++ trunk/extractor/helpers.c 2008-08-22 16:11:25 UTC (rev 104)
@@ -37,17 +37,28 @@
* \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 namenr number to base file name on
* \param ext extension of entry to add
*/
-void add_entry(struct file_s **list, int cnt, const char *ext) {
+void add_entry_nr(struct file_s **list, int cnt, int namenr, 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);
+ snprintf(l[cnt].name, 50, "%i.%s", namenr, ext);
*list = l;
}
+/**
+ * \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) {
+ add_entry_nr(list, cnt, cnt, ext);
+}
+
#define BLOCK_SIZE 4096
/**
* \brief copy data from one file into another
Modified: trunk/extractor/helpers.h
===================================================================
--- trunk/extractor/helpers.h 2008-08-22 16:10:43 UTC (rev 103)
+++ trunk/extractor/helpers.h 2008-08-22 16:11:25 UTC (rev 104)
@@ -42,6 +42,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_nr(struct file_s **list, int cnt, int namenr, const char *ext);
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);
Added: trunk/extractor/solidsub.c
===================================================================
--- trunk/extractor/solidsub.c (rev 0)
+++ trunk/extractor/solidsub.c 2008-08-22 16:11:25 UTC (rev 104)
@@ -0,0 +1,50 @@
+/**
+ * \file solidsub.c
+ * \brief routines for handling the solid subtitle files extracted from vox.dat
+ *
+ * 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"
+
+static int check_file(FILE *in) {
+ // no safe autodetection available
+ return 0;
+}
+
+static file_t *get_list(FILE *in) {
+ int namenr = 0;
+ int cnt = 0;
+ int img = 0;
+ file_t *list = calloc(1, sizeof(file_t));
+ rewind(in);
+ while (!feof(in) && cnt < MAX_FILES) {
+ uint32_t size = read_le32(in);
+ if (!size) continue;
+ add_entry_nr(&list, cnt, namenr, img ? "img" : "txt");
+ list[cnt].start = ftell(in);
+ list[cnt].len = size;
+ cnt++;
+ fseek(in, size, SEEK_CUR);
+ if (img) namenr++;
+ img = !img;
+ }
+ return list;
+}
+
+const fmt_desc_t solidsub_fmt = {
+ "solidsub",
+ "MetalGear Solid: TS subtitles",
+ "MetalGear Solid: TS subtitles (*.sub)",
+ "*.sub",
+ check_file,
+ 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.
|