Commit e066db4f authored by Derrick Sobodash's avatar Derrick Sobodash

Cleaned up the output.

Fixed the copyright line.
Relicensed under BSD.
parent 1dc15650
Copyright (c) 2012, Derrick Sobodash
Copyright (c) 2003, 2012 Derrick Sobodash
All rights reserved.
......
#!/usr/bin/php
<?php
echo ("\nqdabuild 1.0 (c) 2003 Derrick Sobodash\n");
set_time_limit(6000000);
if ($argc < 2) { DisplayOptions(); die; }
else { $path = $argv[1]; }
// Simple routine to read in a directory listing and split it to an array
$mydir="";
$orgfile = "$path";
if ($handle = opendir($orgfile)) {
while (false !== ($file = readdir($handle))) {
$mydir .= $orgfile . "/$file\n";
}
closedir($handle);
}
$filelist = split("\n", $mydir);
print "Staring new header... ";
$header = str_pad((pack("V*", 0) . "QDA0" . pack("V*", (count($filelist) - 3))) , 0x100, chr(0), STR_PAD_RIGHT);
print "done!\n";
$binary = "";
for ($i=2; $i < (count($filelist)-1); $i++) {
print "Adding " . $filelist[$i] . "... ";
$fd = fopen($filelist[$i], "rb");
$file = fread($fd, filesize($filelist[$i]));
fclose($fd);
$header .= pack("V*", (0x100 + (268 * (count($filelist) - 3)) + strlen($binary))) .
pack("V*", strlen($file)) . pack("V*", strlen($file)) .
str_pad($filelist[$i], 256, chr(0), STR_PAD_RIGHT);
$binary .= $file;
print "done!\n";
}
print "Writing new resource file... ";
$fo = fopen("$path-a.qda", "w");
fputs($fo, $header . $binary);
fclose($fo);
print "done!\n";
echo ("All done!...\n\n");
function DisplayOptions() {
echo ("Builds a QDA resource for Akuji the Demon\n usage: qdabuild [input path]\n\n");
}
?>
#!/usr/bin/php -q
<?php
/*
qdabuild
Assembles a QDA package file using a directory of resources.
Version: 1.0
Author: Derrick Sobodash <derrick@sobodash.com>
Copyright: (c) 2003, 2012 Derrick Sobodash
Web site: https://github.com/sobodash/qdatools/
License: BSD License <http://opensource.org/licenses/bsd-license.php>
*/
echo ("qdabuild 1.0 (cli)\nCopyright (c) 2003, 2012 Derrick Sobodash\n");
set_time_limit(6000000);
if ($argc < 2) { DisplayOptions(); die; }
else { $path = $argv[1]; }
// Simple routine to read in a directory listing and split it to an array
$mydir="";
$orgfile = "$path";
if ($handle = opendir($orgfile)) {
while (false !== ($file = readdir($handle))) {
$mydir .= $orgfile . "/$file\n";
}
closedir($handle);
}
$filelist = split("\n", $mydir);
print "Staring new header... ";
$header = str_pad((pack("V*", 0) . "QDA0" . pack("V*", (count($filelist) - 3))) , 0x100, chr(0), STR_PAD_RIGHT);
print "done!\n";
$binary = "";
for ($i=2; $i < (count($filelist)-1); $i++) {
print "Adding " . $filelist[$i] . "... ";
$fd = fopen($filelist[$i], "rb");
$file = fread($fd, filesize($filelist[$i]));
fclose($fd);
$header .= pack("V*", (0x100 + (268 * (count($filelist) - 3)) + strlen($binary))) .
pack("V*", strlen($file)) . pack("V*", strlen($file)) .
str_pad($filelist[$i], 256, chr(0), STR_PAD_RIGHT);
$binary .= $file;
print "done!\n";
}
print "Writing new resource file... ";
$fo = fopen("$path-a.qda", "w");
fputs($fo, $header . $binary);
fclose($fo);
print "done!\n";
echo ("All done!...\n\n");
function DisplayOptions() {
echo ("Builds a QDA resource.\n usage: qdabuild [input path]\n\n");
}
?>
#!/usr/bin/php
<?php
echo ("\nqdadump 1.0 - (c) 2003 Derrick Sobodash\n");
set_time_limit(6000000);
if ($argc < 2) { DisplayOptions(); die; }
else { $file = $argv[1]; }
$fd = fopen($file, "rb");
fseek($fd, 0x4, SEEK_SET);
$id = fread($fd, 4);
if($id != "QDA0") die(print "Not a valid QDA file!");
print "Reading header... ";
fseek($fd, 0x8, SEEK_SET);
$count = hexdec(bin2hex(strrev(fread ($fd, 1))));
fseek($fd, 0x100, SEEK_SET);
for($i=0; $i<$count; $i++) {
$off[$i] = hexdec(bin2hex(strrev(fread ($fd, 4))));
$size[$i] = hexdec(bin2hex(strrev(fread ($fd, 4))));
$unk[$i] = hexdec(bin2hex(strrev(fread ($fd, 4))));
$name[$i] = rtrim(fread($fd, 256));
}
print "done!\n";
$newdir = substr($file, 0, strlen($file)-4);
mkdir($newdir);
for($i=0; $i<$count; $i++) {
print "Writing " . $name[$i] . "... ";
fseek($fd, $off[$i], SEEK_SET);
$file = fread($fd, $size[$i]);
$fo = fopen("./$newdir/" . $name[$i], "wb");
fputs($fo, $file);
print "done!\n";
}
echo ("All done!...\n\n");
function DisplayOptions() {
echo ("Rips a QDA resource from Akuji the Demon\n usage: qdadump [input file]\n\n");
}
?>
#!/usr/bin/php -q
<?php
/*
qdadump
Extracts the resources from a QDA package file.
Version: 1.0
Author: Derrick Sobodash <derrick@sobodash.com>
Copyright: (c) 2003, 2012 Derrick Sobodash
Web site: https://github.com/sobodash/qdatools/
License: BSD License <http://opensource.org/licenses/bsd-license.php>
*/
echo ("qdadump 1.0 (cli)\nCopyright (c) 2003, 2012 Derrick Sobodash\n");
set_time_limit(6000000);
if ($argc < 2) { DisplayOptions(); die; }
else { $file = $argv[1]; }
$fd = fopen($file, "rb");
fseek($fd, 0x4, SEEK_SET);
$id = fread($fd, 4);
if($id != "QDA0") die(print "Not a valid QDA file!");
print "Reading header... ";
fseek($fd, 0x8, SEEK_SET);
$count = hexdec(bin2hex(strrev(fread ($fd, 1))));
fseek($fd, 0x100, SEEK_SET);
for($i=0; $i<$count; $i++) {
$off[$i] = hexdec(bin2hex(strrev(fread ($fd, 4))));
$size[$i] = hexdec(bin2hex(strrev(fread ($fd, 4))));
$unk[$i] = hexdec(bin2hex(strrev(fread ($fd, 4))));
$name[$i] = rtrim(fread($fd, 256));
}
print "done!\n";
$newdir = substr($file, 0, strlen($file)-4);
mkdir($newdir);
for($i=0; $i<$count; $i++) {
print "Writing " . $name[$i] . "... ";
fseek($fd, $off[$i], SEEK_SET);
$file = fread($fd, $size[$i]);
$fo = fopen("./$newdir/" . $name[$i], "wb");
fputs($fo, $file);
print "done!\n";
}
echo ("All done!...\n\n");
function DisplayOptions() {
echo ("Extracts a QDA resource.\n usage: qdadump [input file]\n\n");
}
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment