Remove debug output

This commit is contained in:
King_DuckZ 2020-03-04 02:33:47 +01:00
parent 561f3ed58f
commit 6b838cf720
5 changed files with 95 additions and 15 deletions

View file

@ -5,7 +5,6 @@ import std.exception;
import std.conv : to;
import std.string : fromStringz, toStringz, empty;
import std.format;
import std.stdio;
class SQLiteException : Exception {
this(int code, string msg1, string msg2, string file = __FILE__, size_t line = __LINE__) {
@ -36,7 +35,6 @@ class GamesDB {
void* deleme = cast(void*)g_sqlite_db;
string memdb = "file:gamesdb?ptr=0x%s&sz=%d&freeonclose=false".format(deleme, g_sqlite_db.length);
stderr.writeln(memdb);
const int open_ret = sqlite3_open_v2(memdb.toStringz(), &m_db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_URI, "memvfs".toStringz());
if (open_ret)
throw new SQLiteException(open_ret, "opening in-memory database", sqlite3_errmsg(m_db).fromStringz.idup);

View file

@ -1,24 +1,29 @@
module isotoserial;
import std.string : toStringz, fromStringz;
import std.stdio;
import std.exception;
import std.conv : to;
import std.stdint;
extern(C) {
alias iso_listing_callback = int function(void*,const(char)*,int);
struct iso_extract_handle;
alias iso_listing_callback = int function(void*,const(char)*,int,int,iso_extract_handle*);
int scan_iso (const(char)* filename, iso_listing_callback callback, void* user_data);
void extract_file_from_iso (iso_extract_handle*, char*);
private int printer(void*, const(char)* path, int is_dir) {
private int printer(void* user_data, const(char)* path, int is_dir, int size, iso_extract_handle* h) {
auto spath = path.fromStringz;
writef("Entry \"%s\"", spath);
if (is_dir != 0) {
write(" (directory)");
if (!is_dir && spath == "/UMD_DATA.BIN") {
auto buff = new char[size];
extract_file_from_iso(h, buff.ptr);
string* out_str = cast(string*)user_data;
*out_str = buff[0..10].idup;
return 1;
}
else {
return 0;
}
write("\n");
return (spath == "/UMD_DATA.BIN" ? 1 : 0);
}
}
@ -29,9 +34,11 @@ public string iso_to_serial (string path) {
// NPJH-50465|0D506D389F2AA444|0001|G
// ULJM-05530|5A2E0CF722EF6299|0001|G
scan_iso(path.toStringz, &printer, null);
string retval;
scan_iso(path.toStringz, &printer, &retval);
return retval;
return "UCES-00356"; //Tekken Dark Resurrection
//return "UCES-00356"; //Tekken Dark Resurrection
//return "NPJH-50465"; //Hatsune Miku (missing from redump list)
//return "ULJM-05530"; //Undead Knights (missing from redump list)
//return "NPEG-00003"; //fl0w (missing from redump list)

View file

@ -5,10 +5,9 @@ import gamesdb;
import isotoserial;
int main() {
writeln("hello world");
Unique!GamesDB db = new GamesDB;
string serial = iso_to_serial("/home/michele/deleme/b-mikuex.iso");
writefln("Title for game %s is %s", serial, db.find_by_serial(serial));
writeln(db.find_by_serial(serial));
return 0;
}

View file

@ -0,0 +1,76 @@
module isotoserial;
import std.string : toStringz, fromStringz;
import std.stdio;
import std.exception;
import std.conv : to;
private enum LibarchiveRet : int {
ARCHIVE_EOF = 1, /* Found end of archive. */
ARCHIVE_OK = 0, /* Operation was successful. */
ARCHIVE_RETRY = (-10), /* Retry might succeed. */
ARCHIVE_WARN = (-20), /* Partial success. */
/* For example, if write_header "fails", then you can't push data. */
ARCHIVE_FAILED = (-25), /* Current operation cannot complete. */
/* But if write_header is "fatal," then this archive is dead and useless. */
ARCHIVE_FATAL = (-30), /* No more operations are possible. */
}
public class LibarchiveException : Exception {
this(LibarchiveRet code, string file = __FILE__, size_t line = __LINE__) {
super("libarchive error " ~ to!string(cast(int)code) ~ ": " ~ to!string(code), file, line);
}
}
extern(C) {
struct archive;
struct archive_entry;
archive* archive_read_new();
int archive_read_open_filename(archive*, const(char)* filename, size_t block_size);
int archive_read_next_header(archive*, archive_entry**);
int archive_read_data_skip(archive*);
int archive_read_free(archive*);
int archive_read_support_format_iso9660(archive*);
int archive_read_support_format_empty(archive*);
int archive_read_support_format_mtree(archive*);
int archive_read_support_format_raw(archive*);
int archive_read_support_format_tar(archive*);
int archive_read_support_format_all(archive*);
int archive_read_support_compression_none(archive*);
int archive_read_support_compression_all(archive*);
int archive_read_close(archive*);
const(char)* archive_entry_pathname(archive_entry*);
}
public string iso_to_serial (string path) {
archive* arc = archive_read_new();
scope(exit) archive_read_free(arc);
// open UMD_DATA.BIN
// examples:
// NPEG-00003|8F33052F02B34E56|0001|G
// NPJH-50465|0D506D389F2AA444|0001|G
// ULJM-05530|5A2E0CF722EF6299|0001|G
archive_read_support_format_iso9660(arc);
archive_read_support_format_empty(arc);
archive_read_support_format_raw(arc);
//archive_read_support_format_tar(arc);
archive_read_support_compression_none(arc);
const LibarchiveRet r = cast(LibarchiveRet)archive_read_open_filename(arc, path.toStringz, 10240);
if (r != LibarchiveRet.ARCHIVE_OK)
throw new LibarchiveException(r);
archive_entry* entry;
writefln("reading content of %s...", path);
while (archive_read_next_header(arc, &entry) == LibarchiveRet.ARCHIVE_OK) {
writefln("path: \"%s\"", archive_entry_pathname(entry).fromStringz);
archive_read_data_skip(arc);
}
return "UCES-00356"; //Tekken Dark Resurrection
//return "NPJH-50465"; //Hatsune Miku (missing from redump list)
//return "ULJM-05530"; //Undead Knights (missing from redump list)
//return "NPEG-00003"; //fl0w (missing from redump list)
}

View file

@ -1561,7 +1561,7 @@ default_charset(void)
if (codeset != NULL)
free(codeset);
#define verbose 1
#define verbose 0
if (verbose > 0 && charset != NULL) {
error(_("Setting input-charset to '%s' from locale.\n"),
charset);