summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xenogears/main_dump.cpp148
-rw-r--r--Xenogears/reinsert.cpp12
-rw-r--r--Xenogears/script-comp.cpp105
-rw-r--r--Xenogears/script-dec.cpp52
-rw-r--r--generic/Exceptions.cpp20
-rw-r--r--generic/Handle.cpp14
-rw-r--r--generic/Input.cpp2
-rw-r--r--generic/String.cpp6
-rw-r--r--includes/Handle.h2
-rw-r--r--includes/Input.h2
-rw-r--r--includes/generic.h16
11 files changed, 190 insertions, 189 deletions
diff --git a/Xenogears/main_dump.cpp b/Xenogears/main_dump.cpp
index fa61db5..60c15df 100644
--- a/Xenogears/main_dump.cpp
+++ b/Xenogears/main_dump.cpp
@@ -28,9 +28,10 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
-#include "fileutils.h"
#include "cdutils.h"
#include "generic.h"
+#include "Input.h"
+#include "Output.h"
unsigned int tourne = 0;
@@ -44,48 +45,45 @@ struct t_index_tab {
struct t_sequence {
unsigned int n;
unsigned int sum;
- char *prefix;
- char *name;
+ String prefix;
+ String name;
int type;
};
-char *title, *iso_filename, *prefix;
+String title, iso_filename, prefix;
unsigned long iso_size;
unsigned int nb_records, nb_seqs = 0;
struct t_sequence sequences[1000];
-long check_iso(int f_iso);
-void read_files(int f_iso);
-void file_dump(int f_iso, unsigned long debut, unsigned long taille, long num, int seq);
-int process_def_file(int f_def);
+long check_iso(Handle * f_iso);
+void read_files(Handle * f_iso);
+void file_dump(Handle * f_iso, unsigned long debut, unsigned long taille, long num, int seq);
+int process_def_file(Handle * f_def);
-unsigned char user_data[2352];
+Byte user_data[2352];
int main(int argc, char **argv)
{
- int f_def, f_iso;
+ Handle * f_def, * f_iso;
verbosity = 3;
- fprintf(stderr,
+ printm(M_BARE,
"Xenogears File Extractor by Nicolas \"Pixel\" Noble\n"
"Highly based upon the Chrono Cross File Extractor By Yazoo\n\n");
if (argc != 3) {
- fprintf(stderr, "Usage: %s <definition_file.sqr> <iso_file_name>\nSee readme.txt for details\n",
+ printm(M_BARE, "Usage: %s <definition_file.sqr> <iso_file_name>\nSee readme.txt for details\n",
argv[0]);
exit(-1);
}
printm(M_STATUS, "Processing file %s...\n", argv[1]);
- if ((f_def = open(argv[1], O_RDONLY)) < 0) {
- printm(M_ERROR, "Unable to open the definition file \"%s\"...\n", argv[1]);
- exit(-1);
- }
+ f_def = new Input(argv[1]);
if (process_def_file(f_def)) {
- close(f_def);
+ delete f_def;
printm(M_ERROR, "Unable to process the definition file \"%s\"...\n", argv[1]);
exit(-1);
}
@@ -93,55 +91,47 @@ int main(int argc, char **argv)
iso_filename = argv[2];
printm(M_STATUS, "Begin processing iso file.\n");
- if ((f_iso = open(iso_filename, O_RDONLY)) < 0) {
- printm(M_ERROR, "Unable to open the iso file \"%s\"...\n", iso_filename);
- exit(-1);
- }
+ f_iso = new Input(iso_filename);
if (check_iso(f_iso)) {
- printm(M_ERROR, "Invalid iso file for %s\n", title);
+ printm(M_ERROR, "Invalid iso file for " + title + "\n");
printm(M_ERROR, "===> Make sure you are using a Genuine iso file.\n");
} else {
- printm(M_INFO, "Genuine %s iso detected.\n", title);
+ printm(M_INFO, "Genuine " + title + " iso detected.\n");
}
printm(M_STATUS, "Entering files read sequence\n");
read_files(f_iso);
- close(f_iso);
+ delete f_iso;
exit(0);
}
/*
* Ugly but working... for now
*/
-int process_def_file(int h_f_def)
+int process_def_file(Handle * f_def)
{
- char t[1024], *p;
+ String t;
unsigned int n, sum = 0;
- FILE * f_def = fdopen(h_f_def, "r");
- if ((p = strchr(fgets(t, 1024, f_def), '\n')) == NULL)
- return 1;
- *p = 0;
- printm(M_INFO, "Read title: %s\n", t);
- title = strdup(t);
+ *f_def >> t;
+ printm(M_INFO, "Read title: " + t + "\n");
+ title = t;
- if (fscanf(f_def, "%lu\n", &iso_size) != 1)
- return 1;
+ *f_def >> t;
+ iso_size = t.to_int();
printm(M_INFO, "Read iso size: %lu bytes\n", iso_size);
- if ((p = strchr(fgets(t, 1024, f_def), '\n')) == NULL)
- return 1;
- *p = 0;
- printm(M_INFO, "Read global directory prefix: %s\n", t);
- prefix = strdup(t);
+ *f_def >> t;
+ printm(M_INFO, "Read global directory prefix: " + t + "\n");
+ prefix = t;
- if (fscanf(f_def, "%u\n", &nb_records) != 1)
- return 1;
+ *f_def >> t;
+ nb_records = t.to_int();
printm(M_INFO, "Read total of records: %u\n", nb_records);
while (1) {
- if (fscanf(f_def, "%u\n", &n) != 1)
- return 1;
+ *f_def >> t;
+ n = t.to_int();
if (!n) {
if (sum == nb_records) {
printm(M_INFO, "Definition file seems coherent\n");
@@ -154,36 +144,32 @@ int process_def_file(int h_f_def)
sum += n;
sequences[nb_seqs].n = n;
sequences[nb_seqs].sum = sum;
- if ((p = strchr(fgets(t, 1024, f_def), '\n')) == NULL)
- return 1;
- *p = 0;
- sequences[nb_seqs].prefix = strdup(t);
- if (fscanf(f_def, "%u\n", &n) != 1)
- return 1;
+ *f_def >> t;
+ sequences[nb_seqs].prefix = t;
+ *f_def >> t;
+ n = t.to_int();
sequences[nb_seqs].type = n;
- if ((p = strchr(fgets(t, 1024, f_def), '\n')) == NULL)
- return 1;
- *p = 0;
- sequences[nb_seqs].name = strdup(t);
- printm(M_INFO, "Read definition of sequence %i:\n===> %5i (sum = %5i) chunks of %s (%s)\n",
- nb_seqs, n, sum, t, sequences[nb_seqs].prefix);
+ *f_def >> t;
+ sequences[nb_seqs].name = t;
+ printm(M_INFO, "Read definition of sequence %i:\n===> %5i (sum = %5i) chunks of " + t +
+ " (" + sequences[nb_seqs].prefix + ")\n", nb_seqs, n, sum);
nb_seqs++;
}
}
-long check_iso(int f_iso)
+long check_iso(Handle * f_iso)
{
unsigned long length;
- length = filesize(f_iso);
- printm(M_INFO, "Filesize of iso file %s is %ld bytes\n", iso_filename, length);
+ length = f_iso->GetSize();
+ printm(M_INFO, "Filesize of iso file " + iso_filename + " is %ld bytes\n", length);
if (length != iso_size) {
return 1;
}
return 0;
}
-void read_files(int f_iso)
+void read_files(Handle * f_iso)
{
t_index_tab index_tab[10000];
unsigned char t[8];
@@ -193,7 +179,7 @@ void read_files(int f_iso)
unsigned long indexer;
struct t_index_tab *p = (struct t_index_tab *) t;
- unsigned char fat[32768];
+ Byte fat[32768];
#define INDEXPOS 24
@@ -240,39 +226,29 @@ void read_files(int f_iso)
fprintf(stderr, "\n");
}
-void file_dump(int f_iso, unsigned long debut, unsigned long taille, long num, int seq)
+void file_dump(Handle * f_iso, unsigned long debut, unsigned long taille, long num, int seq)
{
long i;
long nbsects;
- char nom[1000] = "";
- char *extention = ".out";
- char nom_t[1000] = "";
- int f_out;
+ String nom;
+ String extension = ".out";
+ String nom_t;
+ Handle * f_out;
char type = sequences[seq].type;
char ptitbidule[] = "-\\|/";
- sprintf(nom_t, "%ld", num);
+ nom_t.set("%04ld", num);
- strcat(nom, "./");
+ nom = "./" + prefix + "/";
- strcat(nom, prefix);
- strcat(nom, "/");
- MKDIR(nom);
+ MKDIR(nom.to_charp());
- strcat(nom, sequences[seq].prefix);
- strcat(nom, "/");
- MKDIR(nom);
+ nom += sequences[seq].prefix + "/";
+ MKDIR(nom.to_charp());
- if (num < 10)
- strcat(nom, "0");
- if (num < 100)
- strcat(nom, "0");
- if (num < 1000)
- strcat(nom, "0");
- strcat(nom, nom_t);
+ nom += nom_t + extension;;
- strcat(nom, extention);
- f_out = open(nom, O_WRONLY | O_CREAT | O_TRUNC, 00644);
+ f_out = new Output(nom);
nbsects = taille / sec_sizes[type];
if (taille % sec_sizes[type])
nbsects++;
@@ -282,11 +258,11 @@ void file_dump(int f_iso, unsigned long debut, unsigned long taille, long num, i
fprintf(stderr, " (%c)\010\010\010\010\010", ptitbidule[((tourne++) >> 8) % 4]);
read_sector(f_iso, user_data, type);
if (i != (nbsects - 1)) {
- write(f_out, user_data, sec_sizes[type]);
+ f_out->write(user_data, sec_sizes[type]);
} else {
- write(f_out, user_data, taille % sec_sizes[type] ? taille % sec_sizes[type] : sec_sizes[type]);
+ f_out->write(user_data, taille % sec_sizes[type] ? taille % sec_sizes[type] : sec_sizes[type]);
}
}
- close(f_out);
- fprintf(stderr, " (*) Dumped file number %4ld - type \"%s\" \r", num, sequences[seq].name);
+ delete f_out;
+ printm(M_BARE, " (*) Dumped file number %4ld - type \"" + sequences[seq].name + "\" \r", num);
}
diff --git a/Xenogears/reinsert.cpp b/Xenogears/reinsert.cpp
index 1227fcc..440e444 100644
--- a/Xenogears/reinsert.cpp
+++ b/Xenogears/reinsert.cpp
@@ -113,8 +113,7 @@ int process_def_file(Handle * f_def)
title = t;
*f_def >> t;
- if (sscanf(t.to_charp(), "%lu\n", &iso_size) != 1)
- return 1;
+ iso_size = t.to_int();
printm(M_INFO, "Read iso size: %lu bytes\n", iso_size);
*f_def >> t;
@@ -122,14 +121,12 @@ int process_def_file(Handle * f_def)
prefix = t;
*f_def >> t;
- if (sscanf(t.to_charp(), "%u\n", &nb_records) != 1)
- return 1;
+ nb_records = t.to_int();
printm(M_INFO, "Read total of records: %u\n", nb_records);
while (1) {
*f_def >> t;
- if (sscanf(t.to_charp(), "%u\n", &n) != 1)
- return 1;
+ n = t.to_int();
if (!n) {
if (sum == nb_records) {
printm(M_INFO, "Definition file seems coherent\n");
@@ -145,8 +142,7 @@ int process_def_file(Handle * f_def)
*f_def >> t;
sequences[nb_seqs].prefix = t;
*f_def >> t;
- if (sscanf(t.to_charp(), "%u\n", &n) != 1)
- return 1;
+ n = t.to_int();
sequences[nb_seqs].type = n;
*f_def >> t;
sequences[nb_seqs].name = t;
diff --git a/Xenogears/script-comp.cpp b/Xenogears/script-comp.cpp
index 41fb00b..ee71d8f 100644
--- a/Xenogears/script-comp.cpp
+++ b/Xenogears/script-comp.cpp
@@ -1,97 +1,98 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
#include "lzss.h"
-#include "fileutils.h"
+#include "Input.h"
+#include "Output.h"
+#include "generic.h"
-void process_one_file(FILE * f, FILE * d, int n) {
- char nom_du_fichier[100];
+void process_one_file(Handle * f, Handle * d, int n) {
+ String nom_du_fichier;
char zeros[4] = {0, 0, 0, 0}, * datas;
long script_position, true_length, delta, data_length;
- FILE * f_part;
+ Handle * f_part;
- fprintf(stderr, " Copying header\n");
+ printm(M_BARE, " Copying header\n");
- fseek(f, 0x14c, SEEK_SET);
- fread(&script_position, 1, 4, f);
- fseek(f, 0, SEEK_SET);
+ f->seek(0x14c);
+ f->read(&script_position, 4);
+ f->seek(0);
copy(f, d, script_position);
- fseek(f, 0x150, SEEK_SET);
- fread(&script_position, 1, 4, f);
- fseek(f, script_position, SEEK_SET);
+ f->seek(0x150);
+ f->read(&script_position, 4);
+ f->seek(script_position);
- data_length = filesize(f) - script_position;
+ data_length = f->GetSize() - script_position;
datas = (char *) malloc(data_length);
- fread(datas, 1, data_length, f);
+ f->read(datas, data_length);
- fprintf(stderr, " Processing script\n");
- sprintf(nom_du_fichier, "xeno_d1/ROOMS/%04i/script.comp", n);
+ printm(M_BARE, " Processing script\n");
+ nom_du_fichier = String("xeno_d1/ROOMS/") + n + "/script.comp";
- f_part = fopen(nom_du_fichier, "r");
- true_length = filesize(f_part);
+ f_part = new Input(nom_du_fichier);
+ true_length = f_part->GetSize();
- script_position = fseek(d, 0, SEEK_CUR);
- fseek(d, 0x14c, SEEK_SET);
- fwrite(&script_position, 1, 4, d);
- fseek(d, 0x128, SEEK_SET);
- fwrite(&true_length, 1, 4, d);
- fseek(d, 0, SEEK_END);
+ script_position = d->seek(0);
+ d->seek(0x14c);
+ d->write(&script_position, 4);
+ d->seek(0x128);
+ d->write(&true_length, 4);
+ d->seek(0, SEEK_END);
lzss_comp(f_part, d, &delta);
+
+ delete f_part;
- fclose(f_part);
-
- script_position = fseek(d, 0, SEEK_CUR);
+ script_position = d->tell();
if ((true_length = (script_position & 3))) {
- fwrite(zeros, 1, 4 - true_length, d);
+ d->write(zeros, 4 - true_length);
}
- fprintf(stderr, " Processing extra datas\n");
- script_position = fseek(d, 0, SEEK_CUR);
- fseek(d, 0x150, SEEK_SET);
- fwrite(&script_position, 1, 4, d);
- fseek(d, 0, SEEK_END);
+ printm(M_BARE, " Processing extra datas\n");
+ script_position = d->tell();
+ d->seek(0x150);
+ d->write(&script_position, 4);
+ d->seek(0);
- fwrite(datas, 1, data_length, d);
+ d->write(datas, data_length);
free(datas);
}
int main(int argc, char ** argv)
{
- FILE * f_script_comp, * f_new_script;
+ Handle * f_script_comp, * f_new_script;
int i;
int num = 0;
- char nom_du_fichier[100];
+ String nom_du_fichier;
for (i = 384; i < 1844; i = i + 2) {
- fprintf(stderr, "CD1 - File %d -> Script %d\n", i, num);
- sprintf(nom_du_fichier, "xeno_d1/ROOMS/%04d.out", i);
- f_script_comp = fopen(nom_du_fichier, "r");
- sprintf(nom_du_fichier, "xeno_d1/ROOMS/%04d.out-new", i);
- f_new_script = fopen(nom_du_fichier, "w");
+ printm(M_BARE, "CD1 - File %d -> Script %d\n", i, num);
+ nom_du_fichier.set("xeno_d1/ROOMS/%04d.out", i);
+ f_script_comp = new Input(nom_du_fichier);
+ nom_du_fichier.set("xeno_d1/ROOMS/%04d.out-new", i);
+ f_new_script = new Output(nom_du_fichier);
process_one_file(f_script_comp, f_new_script, num);
- fclose(f_script_comp);
+ delete f_script_comp;
+ delete f_new_script;
num++;
}
num = 0;
for (i = 379; i < 1838; i = i + 2) {
- fprintf(stderr, "CD2 - File %d -> Script %d\n", i, num);
- sprintf(nom_du_fichier, "xeno_d2/ROOMS/%04d.out", i);
- f_script_comp = fopen(nom_du_fichier, "r");
- sprintf(nom_du_fichier, "xeno_d2/ROOMS/%04d.out-new", i);
- f_new_script = fopen(nom_du_fichier, "w");
+ printm(M_BARE, "CD2 - File %d -> Script %d\n", i, num);
+ nom_du_fichier.set("xeno_d2/ROOMS/%04d.out", i);
+ f_script_comp = new Input(nom_du_fichier);
+ nom_du_fichier.set("xeno_d2/ROOMS/%04d.out-new", i);
+ f_new_script = new Output(nom_du_fichier);
process_one_file(f_script_comp, f_new_script, num);
- fclose(f_script_comp);
- num++;
+ delete f_script_comp;
+ delete f_new_script;
+ num++;
}
- fprintf(stderr, "Done !\n");
+ printm(M_BARE, "Done !\n");
}
diff --git a/Xenogears/script-dec.cpp b/Xenogears/script-dec.cpp
index 2a1b0f3..81dfea3 100644
--- a/Xenogears/script-dec.cpp
+++ b/Xenogears/script-dec.cpp
@@ -2,69 +2,71 @@
#include <stdlib.h>
#include <unistd.h>
#include "lzss.h"
-#include "fileutils.h"
+#include "String.h"
+#include "Input.h"
+#include "Output.h"
-void process_one_file(FILE * f, int d, int n) {
- char nom_du_fichier[100];
+void process_one_file(Handle * f, int d, int n) {
+ String nom_du_fichier;
long script_position, true_length;
int i;
- FILE * f_out;
+ Handle * f_out;
- if (filesize(f) == 24) return;
+ if (f->GetSize() == 24) return;
- sprintf(nom_du_fichier, "xeno_d%d/ROOMS/%04i", d, n);
- MKDIR(nom_du_fichier);
+ nom_du_fichier.set("xeno_d%d/ROOMS/%04i", d, n);
+ MKDIR(nom_du_fichier.to_charp());
i = 7;
// for (i = 0; i < 9; i++) {
-// fprintf(stderr, " Processing part %i\n", i);
- sprintf(nom_du_fichier, "xeno_d%d/ROOMS/%04i/script.comp", d, n);
+// printm(M_BARE, " Processing part %i\n", i);
+ nom_du_fichier.set("xeno_d%d/ROOMS/%04i/script.comp", d, n);
// sprintf(nom_du_fichier, "xeno_d%d/ROOMS/%04i/part-%i", d, n, i);
- f_out = fopen(nom_du_fichier, "w");
- fseek(f, 0x130 + i * 4, SEEK_SET);
- fread(&script_position, 1, 4, f);
- fseek(f, 0x10c + i * 4, SEEK_SET);
- fread(&true_length, 1, 4, f);
- fseek(f, script_position, SEEK_SET);
+ f_out = new Output(nom_du_fichier);
+ f->seek(0x130 + i * 4);
+ f->read(&script_position, 4);
+ f->seek(0x10c + i * 4);
+ f->read(&true_length, 4);
+ f->seek(script_position);
lzss_decomp(f, f_out, true_length);
// if (i == 7) {
// fseek(f_out, 0, SEEK_SET);
// fread(&true_length, 4, 1, f_out);
-// fprintf(stderr, " (seems to be the script number %i)\n", true_length);
+// printm(M_BARE, " (seems to be the script number %i)\n", true_length);
// }
- fclose(f_out);
+ delete f_out;
// }
}
int main(void)
{
- FILE * f_script_comp;
+ Handle * f_script_comp;
int i;
int num = 0;
char nom_du_fichier[100];
for (i = 384; i < 1844; i = i + 2) {
- fprintf(stderr, "CD 1 - File %d -> Script %d\n", i, num);
+ printm(M_BARE, "CD 1 - File %d -> Script %d\n", i, num);
sprintf(nom_du_fichier, "xeno_d1/ROOMS/%04d.out", i);
- f_script_comp = fopen(nom_du_fichier, "r");
+ f_script_comp = new Input(nom_du_fichier);
process_one_file(f_script_comp, 1, num);
- fclose(f_script_comp);
+ delete f_script_comp;
num++;
}
num = 0;
for (i = 379; i < 1838; i = i + 2) {
- fprintf(stderr, "CD 2 - File %d -> Script %d\n", i, num);
+ printm(M_BARE, "CD 2 - File %d -> Script %d\n", i, num);
sprintf(nom_du_fichier, "xeno_d2/ROOMS/%04d.out", i);
- f_script_comp = fopen(nom_du_fichier, "r");
+ f_script_comp = new Input(nom_du_fichier);
process_one_file(f_script_comp, 2, num);
- fclose(f_script_comp);
+ delete f_script_comp;
num++;
}
- fprintf(stderr, "Done !\n");
+ printm(M_BARE, "Done !\n");
}
diff --git a/generic/Exceptions.cpp b/generic/Exceptions.cpp
index 564362e..f24c0fb 100644
--- a/generic/Exceptions.cpp
+++ b/generic/Exceptions.cpp
@@ -82,15 +82,16 @@ void * xmalloc(size_t s) throw (GeneralException) {
return 0;
}
- if (!(r = (char *) ::malloc(s + sizeof(size_t)))) {
- throw MemoryException(s + sizeof(size_t));
+ if (!(r = (char *) ::malloc(s + 2 * sizeof(size_t)))) {
+ throw MemoryException(s + 2 * sizeof(size_t));
}
- memset(r, 0, s + sizeof(size_t));
+ memset(r, 0, s + 2 * sizeof(size_t));
*((size_t *)r) = s;
+ *(((size_t *)r) + 1) = 0xdeedbeef;
- return (void *)(r + sizeof(size_t));
+ return (void *)(r + 2 * sizeof(size_t));
}
void * xrealloc(void * ptr, size_t s) {
@@ -118,15 +119,16 @@ void * xrealloc(void * ptr, size_t s) {
#endif
void xfree(void *& p) {
- if (p) {
- ::free(((char *)p) - sizeof(size_t));
- p = 0;
- }
+ xfree(((char *)p));
}
void xfree(char *& p) {
if (p) {
- ::free(p - sizeof(size_t));
+ if (*(((size_t *)p) - 1) != 0xdeedbeef) {
+ fprintf(stderr, "Error: trying to xfree() a non xmalloc()ed bloc.\n");
+ exit(-1);
+ }
+ ::free(p - 2 * sizeof(size_t));
p = 0;
}
}
diff --git a/generic/Handle.cpp b/generic/Handle.cpp
index 44b01de..e95a28a 100644
--- a/generic/Handle.cpp
+++ b/generic/Handle.cpp
@@ -297,3 +297,17 @@ bool Handle::CanSeek() {
off_t Handle::seek(off_t, int) throw(GeneralException) {
throw IOGeneral("Handle " + GetName() + " can't seek");
}
+
+void copy(Handle * s, Handle * d, ssize_t size) {
+ long i;
+ unsigned char c;
+ long r;
+
+ for (i = 0; (i < size) || (size < 0); i++) {
+ r = s->read(&c, 1);
+ if (r == 0) {
+ break;
+ }
+ d->write(&c, 1);
+ }
+}
diff --git a/generic/Input.cpp b/generic/Input.cpp
index a51ee65..b7ee99c 100644
--- a/generic/Input.cpp
+++ b/generic/Input.cpp
@@ -13,7 +13,7 @@
#define _(x) x
#endif
-Input::Input(String no) throw (GeneralException) :
+Input::Input(const String & no) throw (GeneralException) :
Handle(no.strlen() ? open(no.to_charp(), O_RDONLY) : dup(0)),
n(no) {
if (GetHandle() < 0) {
diff --git a/generic/String.cpp b/generic/String.cpp
index 0f4da24..c389c13 100644
--- a/generic/String.cpp
+++ b/generic/String.cpp
@@ -23,17 +23,13 @@ String::String(char c) : siz(1) {
str = t;
}
-String::String(const char * s, ...) : str(s ? Base::strdup(s) : Base::strdup("")) {
+String::String(const char * s, ...) {
va_list ap;
- if (!s)
- return;
-
/* This causes a warning: cannot pass objects of type `const String' through `...'
but it is not really a problem. */
va_start(ap, s);
vsnprintf(t, BUFSIZ, s, ap);
- free(str);
str = Base::strdup(t);
va_end(ap);
siz = ::strlen(str);
diff --git a/includes/Handle.h b/includes/Handle.h
index 368ec40..4bab879 100644
--- a/includes/Handle.h
+++ b/includes/Handle.h
@@ -54,6 +54,8 @@ class Handle : public Base {
Handle & operator<<(Handle &, const String &);
Handle & operator>>(Handle &, String &);
+void copy(Handle *, Handle *, ssize_t = -1);
+
#else
#error This only works with a C++ compiler
#endif
diff --git a/includes/Input.h b/includes/Input.h
index 8e3e84e..d1755e7 100644
--- a/includes/Input.h
+++ b/includes/Input.h
@@ -9,7 +9,7 @@
class Input : public Handle {
public:
- Input(String = "") throw (GeneralException);
+ Input(const String & = "") throw (GeneralException);
Input(const Input &);
virtual ~Input() {}
virtual bool CanWrite();
diff --git a/includes/generic.h b/includes/generic.h
index 41f3a5f..9c5b7a4 100644
--- a/includes/generic.h
+++ b/includes/generic.h
@@ -19,6 +19,9 @@
#ifndef __GENERIC_H__
#define __GENERIC_H__
+#ifdef __cplusplus
+#include "String.h"
+#endif
#define M_BARE -1
#define M_ERROR 0
@@ -77,9 +80,7 @@ extern char verbosity;
char ** split(char * s, char t);
#ifdef __cplusplus
-class String;
void printm(int level, String fmt, ...);
-#include "String.h"
#ifndef MAX
template<class T>
@@ -106,4 +107,15 @@ inline T MIN(T a, T b) {
#endif
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#if defined __linux__ || defined __CYGWIN32__
+#define MKDIR(name) mkdir(name, 0777)
+#elif defined __MINGW32_VERSION
+#define MKDIR mkdir
+#else
+#error Unknow compiler/platform
+#endif
+
#endif