From d38e80ee04afe582e70150d3884e56c05f3fd7a8 Mon Sep 17 00:00:00 2001 From: pixel Date: Sat, 27 Nov 2004 21:44:44 +0000 Subject: Large dos2unix commit... --- ToD/c_dumper.cpp | 280 +++++++++++++++++++++++++++---------------------------- 1 file changed, 140 insertions(+), 140 deletions(-) (limited to 'ToD/c_dumper.cpp') diff --git a/ToD/c_dumper.cpp b/ToD/c_dumper.cpp index 669a564..edbd8df 100644 --- a/ToD/c_dumper.cpp +++ b/ToD/c_dumper.cpp @@ -1,140 +1,140 @@ -#include -#include -#include -#include "generic.h" -#include "Main.h" -#include "Input.h" -#include "Output.h" - -CODE_BEGINS -int startup() throw (GeneralException) -{ - long valpos = 0; - long valpos2 = 0; - long valposnext = 0; - long valtaille = 0; - char doublon[8]; - char doublon2[8]; - unsigned char pos[3]; - unsigned char taille[3]; - int index = 0; - - Byte segment[257]; - - Input * handleindex = new Input("M.B"); - Input * handlearchi = new Input("M.DAT"); - - while(index!=1315) { - Output * outfile; - String nom_fichier; - - valposnext = valpos + valtaille; - - handleindex->seek(1, SEEK_CUR); // on saute le premier octet - handleindex->read(pos, 3); - valpos = pos[0] + (pos[1] << 8) + (pos[2] << 16); - - handleindex->seek(1, SEEK_CUR); // on saute le premier octet - handleindex->read(taille, 3); - valtaille = taille[0] + (taille[1] << 8) + (taille[2] << 16); - - valpos2 = handleindex->tell(); // sauve la position - doublon[0] = 0; - doublon[1] = pos[0]; - doublon[2] = pos[1]; - doublon[3] = pos[2]; - doublon[4] = 0; - doublon[5] = taille[0]; - doublon[6] = taille[1]; - doublon[7] = taille[2]; // on construit la chaine contenant le pointeur - handleindex->seek(0); - for(int i = 0; i < (valpos2 - 8); i += 8) { - handleindex->read(doublon2, 8); - if(memcmp(doublon, doublon2, 8) == 0) { - printm(M_BARE, "\nIgnore fichier d'index %d\n", index); - index++; - break; - } - } - handleindex->seek(valpos2); // on remet la position au bon endroit - - if (memcmp(doublon, doublon2, 8) == 0) { - continue; - } - - handlearchi->seek(valpos << 8); - - nom_fichier.set("extract\\tod_%04d.out", index); - - ///////////////////// - // A decommenter si les fichiers sont déjà extrait du .DAT - ///////////////////// - - // outfile = fopen(nom_fichier,"rb"); // unarc - - //////////////////// - // Commenter à partir de là jusqu'à la fin du FOR si on a déjà extrait les fichiers du .DAT - //////////////////// - - outfile = new Output(nom_fichier); - - for (int i = 0; i < valtaille; i++) { - handlearchi->read(segment, 256); - outfile->write(segment, 256); - } - //////////////////// - - printm(M_BARE, "\rFichier dumpé : %d",index); - //unarc(outfile,index); - delete outfile; - index++; - - } - delete handleindex; - delete handlearchi; - - printm(M_BARE, "\nNombre de fichiers dumpés : %d",index - 1); - return 0; -} - -void unarc(Input * fichier, int num) -{ - int quantite; - int *pos; - long taille; - char *buf; - String nomarchive; - String nomfichier; - Output *fichierout; - - taille = fichier->GetSize(); - - fichier->read(&quantite, 4); - pos = (int *) malloc(4 * quantite); - fichier->read(pos, 4 * quantite); - nomarchive.set("%04d", num); - MKDIR(nomarchive.to_charp()); - - for (int i = 0; i < quantite - 1; i++) { - buf=(char *) malloc(pos[i+1]-pos[i]); - fichier->read(buf, pos[i + 1] - pos[i]); - nomarchive.set("%04d", i); - - fichierout = new Output(nomarchive + nomfichier); - fichierout->write(buf, pos[i + 1] - pos[i]); - delete fichierout; - } - - buf = (char *) malloc(taille - pos[quantite - 1]); - fichier->read(buf, taille - pos[quantite - 1]); - nomfichier.set("%04d", quantite - 1); - - fichierout = new Output(nomarchive + nomfichier); - fichierout->write(buf, taille - pos[quantite - 1]); - delete fichierout; -} - -int Analyse_table() { - return 1; -} -CODE_ENDS +#include +#include +#include +#include "generic.h" +#include "Main.h" +#include "Input.h" +#include "Output.h" + +CODE_BEGINS +int startup() throw (GeneralException) +{ + long valpos = 0; + long valpos2 = 0; + long valposnext = 0; + long valtaille = 0; + char doublon[8]; + char doublon2[8]; + unsigned char pos[3]; + unsigned char taille[3]; + int index = 0; + + Byte segment[257]; + + Input * handleindex = new Input("M.B"); + Input * handlearchi = new Input("M.DAT"); + + while(index!=1315) { + Output * outfile; + String nom_fichier; + + valposnext = valpos + valtaille; + + handleindex->seek(1, SEEK_CUR); // on saute le premier octet + handleindex->read(pos, 3); + valpos = pos[0] + (pos[1] << 8) + (pos[2] << 16); + + handleindex->seek(1, SEEK_CUR); // on saute le premier octet + handleindex->read(taille, 3); + valtaille = taille[0] + (taille[1] << 8) + (taille[2] << 16); + + valpos2 = handleindex->tell(); // sauve la position + doublon[0] = 0; + doublon[1] = pos[0]; + doublon[2] = pos[1]; + doublon[3] = pos[2]; + doublon[4] = 0; + doublon[5] = taille[0]; + doublon[6] = taille[1]; + doublon[7] = taille[2]; // on construit la chaine contenant le pointeur + handleindex->seek(0); + for(int i = 0; i < (valpos2 - 8); i += 8) { + handleindex->read(doublon2, 8); + if(memcmp(doublon, doublon2, 8) == 0) { + printm(M_BARE, "\nIgnore fichier d'index %d\n", index); + index++; + break; + } + } + handleindex->seek(valpos2); // on remet la position au bon endroit + + if (memcmp(doublon, doublon2, 8) == 0) { + continue; + } + + handlearchi->seek(valpos << 8); + + nom_fichier.set("extract\\tod_%04d.out", index); + + ///////////////////// + // A decommenter si les fichiers sont déjà extrait du .DAT + ///////////////////// + + // outfile = fopen(nom_fichier,"rb"); // unarc + + //////////////////// + // Commenter à partir de là jusqu'à la fin du FOR si on a déjà extrait les fichiers du .DAT + //////////////////// + + outfile = new Output(nom_fichier); + + for (int i = 0; i < valtaille; i++) { + handlearchi->read(segment, 256); + outfile->write(segment, 256); + } + //////////////////// + + printm(M_BARE, "\rFichier dumpé : %d",index); + //unarc(outfile,index); + delete outfile; + index++; + + } + delete handleindex; + delete handlearchi; + + printm(M_BARE, "\nNombre de fichiers dumpés : %d",index - 1); + return 0; +} + +void unarc(Input * fichier, int num) +{ + int quantite; + int *pos; + long taille; + char *buf; + String nomarchive; + String nomfichier; + Output *fichierout; + + taille = fichier->GetSize(); + + fichier->read(&quantite, 4); + pos = (int *) malloc(4 * quantite); + fichier->read(pos, 4 * quantite); + nomarchive.set("%04d", num); + MKDIR(nomarchive.to_charp()); + + for (int i = 0; i < quantite - 1; i++) { + buf=(char *) malloc(pos[i+1]-pos[i]); + fichier->read(buf, pos[i + 1] - pos[i]); + nomarchive.set("%04d", i); + + fichierout = new Output(nomarchive + nomfichier); + fichierout->write(buf, pos[i + 1] - pos[i]); + delete fichierout; + } + + buf = (char *) malloc(taille - pos[quantite - 1]); + fichier->read(buf, taille - pos[quantite - 1]); + nomfichier.set("%04d", quantite - 1); + + fichierout = new Output(nomarchive + nomfichier); + fichierout->write(buf, taille - pos[quantite - 1]); + delete fichierout; +} + +int Analyse_table() { + return 1; +} +CODE_ENDS -- cgit v1.2.3