diff --git a/ba/ba1.cpp b/ba/ba1.cpp index 8264042dd..8e45fa3f3 100755 --- a/ba/ba1.cpp +++ b/ba/ba1.cpp @@ -22,6 +22,8 @@ int main(int argc,char** argv) ba1600(argc,argv); break; case 6: ba1700(argc,argv); break; + case 7: + ba1800(argc,argv); break; default: ba1100(argc,argv); break; } diff --git a/ba/ba1.h b/ba/ba1.h index d50d7c95d..11af475df 100755 --- a/ba/ba1.h +++ b/ba/ba1.h @@ -8,6 +8,7 @@ int ba1400(int argc, char** argv); int ba1500(int argc, char** argv); int ba1600(int argc, char* argv[]); int ba1700(int argc, char* argv[]); +int ba1800(int argc, char* argv[]); #endif // __BA1_H diff --git a/ba/ba1600.cpp b/ba/ba1600.cpp index 7bd4a57e0..c0dbffcd0 100755 --- a/ba/ba1600.cpp +++ b/ba/ba1600.cpp @@ -76,22 +76,21 @@ int TInstall_ini::build_list(const TString& module, TString_array& a, int TInstall_ini::build_complete_list(const TString& module, TString_array& a, const char* sommario, bool agg) { + if (sommario && *sommario) + { + TConfig sum(sommario, "Main"); + sum.set("Demo", demo() ? "X" : ""); + } // Lista dei file appartenenti ai sottomoduli del modulo principale (0-9) build_list(module, a, sommario, agg); TAuto_token_string altri(get("Moduli", module)); FOR_EACH_TOKEN(altri, mod) { - const TString80 submodule = mod; + const TString16 submodule = mod; // Lista dei files apparteneti ai sottomoduli esterni (moduli esclusi!) if (submodule.len() > 2) build_list(submodule, a, sommario, agg); } - if (sommario && *sommario) - { - TConfig sum(sommario, "Main"); - sum.set("Demo", demo()); - sum.set("Listino", get("Listino","Main")); - } return a.items(); } @@ -131,15 +130,15 @@ const TString& TInstall_ini::version(const char* module) return ver; } -long TInstall_ini::patch(const char* module) +int TInstall_ini::patch(const char* module) { CHECK(module && *module > ' ', "Can't get version of NULL module"); - long patch = get_long("Patch", module); + int patch = get_int("Patch", module); if (patch == 0 && strlen(module) > 2) { TString16 str; str.strncpy(module, 2); - patch = get_long("Patch", str); + patch = get_int("Patch", str); } return patch; } @@ -680,7 +679,7 @@ protected: bool zip_file(const char* archive, const char* file) const; int split_file(const TFilename& file, long size) const; bool move_file(const TFilename& file, const char* dir) const; - bool zip_module(const TString& module, int patch_level, bool agg) const; + bool zip_module(const TString& module, bool agg, int patch_level) const; const TFilename& build_export_path(TFilename& path) const; @@ -733,10 +732,9 @@ bool TFascicolator_mask::save_handler(TMask_field& f, KEY k) ini.set("PreProcess", m.get(S_PREPROCESS)); ini.set("PostProcess", m.get(S_POSTPROCESS)); } - const int patch_level = m.get_int(S_PATCHLEVEL); const bool agg = f.dlg() == S_SAVEAGG; TFascicolator_mask& fm = (TFascicolator_mask&)m.get_sheet()->mask(); - fm.zip_module(module, patch_level, agg); + fm.zip_module(module, agg, m.get_int(S_PATCHLEVEL)); } return TRUE; } @@ -917,18 +915,16 @@ void TFascicolator_mask::save() } } -bool TFascicolator_mask::zip_file(const char* archive, const char* files) const +bool TFascicolator_mask::zip_file(const char* archive, const char* listfile) const { - TString msg("Creazione del file "); - msg << archive << "..."; + TString msg; + msg << "Creazione del file " << archive << "..."; - TIndwin waitw(50,msg,FALSE,FALSE); + TIndwin waitw(100,msg,FALSE,FALSE); TWait_cursor hourglass; TFilename cmd; int err=0; - // -1 compress faster; -9 compress better - // cmd << "zip.pif " << " -1 " << archive << ' ' << files; - cmd << "zip.pif " << files << " " << archive ; + cmd << "zip.pif " << archive << ' ' << listfile; TExternal_app app(cmd); err = app.run(FALSE, FALSE, FALSE, FALSE); return err == 0; @@ -1009,7 +1005,7 @@ int TFascicolator_mask::split_file(const TFilename& archive, long size) const TFilename cmd; xvt_fsys_convert_dir_to_str(&curdir, cmd.get_buffer(), cmd.size()); cmd.add("zipsplit.pif"); - cmd << " -n " << size << " -b " << archive.path() << " " << archive; + cmd << " -n " << size << " -b " << archive.path() << ' ' << archive; // Salta alla directory temporanea xvt_fsys_convert_str_to_dir((char*)archive.path(), &tmpdir); @@ -1051,7 +1047,7 @@ int TFascicolator_mask::split_file(const TFilename& archive, long size) const return disks; } -bool TFascicolator_mask::zip_module(const TString& main_module, int patch_level, bool agg) const +bool TFascicolator_mask::zip_module(const TString& main_module, bool agg, int patch_level) const { TString_array arr; TInstall_ini ini; @@ -1061,7 +1057,7 @@ bool TFascicolator_mask::zip_module(const TString& main_module, int patch_level, if (agg) { TString16 name; - name.format("%03da.ini", patch_level); + name.format("%04da.ini", patch_level); sommario << name; // Nome del file sommario aggiornamento } else @@ -1082,8 +1078,9 @@ bool TFascicolator_mask::zip_module(const TString& main_module, int patch_level, msg << "Preparazione dei file per " << archivio << " ..."; TFilename filelist; - filelist.temp(); - FILE * fileh=fopen((const char *)filelist,"w"); + filelist.temp("", main_module); + ofstream fileh(filelist); + TProgind pi(arr.items(), msg, TRUE, TRUE); TString cmd(120); @@ -1107,20 +1104,15 @@ bool TFascicolator_mask::zip_module(const TString& main_module, int patch_level, break; } } - // Aggiungo il nome corrente alla lista dei files da compattare - cmd << '\n'; -// fwrite(cmd, sizeof(char), cmd.len(),fileh); - fputs(cmd, fileh); + fileh << cmd << '\n'; } - fclose(fileh); + fileh.close(); if (!aborted) zip_file(archivio, filelist); // Compatto gli eventuali ultimi rimasti - // elimna il file lista-file - fileh = fopen((const char *)filelist,"w"); - fclose(fileh); + // ::remove(filelist); // elimina il file lista-file msg.cut(0); msg << "Separazione del file " << archivio << " ..."; diff --git a/ba/ba1600.h b/ba/ba1600.h index 03a3691a3..18ab99e7d 100755 --- a/ba/ba1600.h +++ b/ba/ba1600.h @@ -18,7 +18,7 @@ public: bool demo() { return get_bool("Demo", "Main"); } const TString& version(const char* module); - long patch(const char* module); + int patch(const char* module); bool update_prices(const char* src_ini); void prices(const char* module, word users, real& full, real& manut); diff --git a/ba/ba1700.cpp b/ba/ba1700.cpp index cea1c7029..c0129d0b9 100755 --- a/ba/ba1700.cpp +++ b/ba/ba1700.cpp @@ -13,7 +13,7 @@ #include "ba1600.h" #include "ba1700a.h" -HIDDEN int compare_version(const char* v1, long p1, const char* v2, long p2) +HIDDEN int compare_version(const char* v1, int p1, const char* v2, int p2) { TString16 ver1(v1), ver2(v2); ver1.trim(); @@ -25,9 +25,7 @@ HIDDEN int compare_version(const char* v1, long p1, const char* v2, long p2) int res = ver1.compare(ver2, -1, TRUE); if (res == 0) - { - res = p1 == p2 ? 0 : (p1 > p2 ? +1 : -1); - } + res = p1 - p2; return res; } @@ -58,7 +56,7 @@ protected: static bool sheet_notify(TSheet_field& s, int r, KEY k); static bool install_handler(TMask_field& fld, KEY key); - bool add_module(TConfig& ini, const TString& module); + bool add_module(TConfig& ini, const TString& module, bool patch); int sort_modules(); void update_version(); @@ -74,7 +72,7 @@ protected: public: bool autoload(); - bool install(const TString& module, long patch); + bool install(const TString& module, int patch); TInstaller_mask(); virtual ~TInstaller_mask(); @@ -83,7 +81,7 @@ public: TInstaller_mask* TInstaller_mask::_curr_mask = NULL; // Copia nello sheet i dati di un modulo prendendoli da un .ini -bool TInstaller_mask::add_module(TConfig& ini, const TString& module) +bool TInstaller_mask::add_module(TConfig& ini, const TString& module, bool patch) { bool ok = ini.set_paragraph(module); if (ok) @@ -95,6 +93,7 @@ bool TInstaller_mask::add_module(TConfig& ini, const TString& module) row.add(ini.get("Versione")); row.add(ini.get("Patch")); row.add(ini.get("Data")); + row.add(patch ? "X" : " ", 9); add(row); } return ok; @@ -106,13 +105,12 @@ static int compare_modules(const TObject** o1, const TObject** o2) TToken_string& ts2 = *(TToken_string*)(*o2); int res = 0; - for (int i = 2; i < 5 && res == 0; i++) + for (int i = 2; i < 5 && res == 0; i++) { TString16 s1 = ts1.get(i); const char* s2 = ts2.get(i); res = s1.compare(s2); } - return res; } @@ -120,21 +118,19 @@ int TInstaller_mask::sort_modules() { rows_array().TArray::sort(compare_modules); + TString16 dis; const int tot = int(items()); - TString16 dis, mod; for (int r = 0; r < tot; r++) { - mod = row(r).get(2); - if (dis == mod) - { + const bool patch = row(r).get_char(9) > ' '; + const char* mod = row(r).get(2); + if (patch) + { + if (dis == mod) disable_row(r); - } - else - { - long patch = row(r).get_long(4); - if (patch == 0) - dis = mod; } + else + dis = mod; } return tot; } @@ -184,7 +180,7 @@ bool TInstaller_mask::autoload() { const TString& module = *row; if (module.len() == 2) - add_module(ini, module); + add_module(ini, module, FALSE); } } else @@ -200,11 +196,11 @@ bool TInstaller_mask::autoload() CHECKS(pos >= 2, "Invalid installation configuration: ", (const char*)ininame); const TString16 module = ininame.mid(pos-2, 2); TConfig ini(ininame, module); - add_module(ini, module); + add_module(ini, module, FALSE); } ininame = path; - ininame.add("??0??a.ini"); + ininame.add("??0???a.ini"); modules.destroy(); list_files(ininame, modules); FOR_EACH_ARRAY_ROW(modules, am, arow) @@ -212,10 +208,10 @@ bool TInstaller_mask::autoload() TString& ininame = *arow; ininame.lower(); const int pos = ininame.find("a.ini"); - CHECKS(pos >= 5, "Invalid installation configuration: ", (const char*)ininame); - const TString16 module = ininame.mid(pos-5, 2); + CHECKS(pos >= 6, "Invalid installation configuration: ", (const char*)ininame); + const TString16 module = ininame.mid(pos-6, 2); TConfig ini(ininame, module); - add_module(ini, module); + add_module(ini, module, TRUE); } } @@ -392,7 +388,7 @@ bool TInstaller_mask::move_module(const TString& module, TInstall_ini& ini, bool return ok; } -bool TInstaller_mask::install(const TString& module, long patchlevel) +bool TInstaller_mask::install(const TString& module, int patchlevel) { bool ok = FALSE; @@ -403,7 +399,7 @@ bool TInstaller_mask::install(const TString& module, long patchlevel) if (patchlevel > 0) { TString16 name; - name.format("%03da.ini"); + name.format("%04da.ini", patchlevel); ininame << name; } else @@ -428,7 +424,9 @@ bool TInstaller_mask::install(const TString& module, long patchlevel) if (!ok) return FALSE; } - TProgind pi(dischi, "Decompressione in corso...", FALSE, TRUE); + TString msg; + msg << "Decompressione del modulo " << module << " in corso..."; + TProgind pi(dischi, msg, FALSE, TRUE); TFilename tempdir; tempdir.tempdir(); TFilename cmdline; @@ -436,10 +434,17 @@ bool TInstaller_mask::install(const TString& module, long patchlevel) { cmdline = path; cmdline.add(module); - cmdline << "inst" << d; - cmdline.ext("zip"); + if (patchlevel > 0) + { + TString16 name; + name.format("%04da", patchlevel); + cmdline << name; + } + else + cmdline << "inst"; + cmdline << d << ".zip"; - ok = fexist(cmdline); + ok = cmdline.exist(); while (!ok) { message_box("Inserire il disco %d di %d del modulo\n%s", @@ -478,8 +483,10 @@ bool TInstaller_mask::install(const TString& module, long patchlevel) } } if (ok) - { - pi.set_text("Aggiornamento in corso..."); + { + msg.cut(0); + msg << "Aggiornamento del modulo " << module << " in corso..."; + pi.set_text(msg); ok = move_module(module, ini, TRUE); TAuto_token_string altri(ini.get("Moduli", module)); @@ -493,20 +500,15 @@ bool TInstaller_mask::install(const TString& module, long patchlevel) { TInstall_ini curini; const TString16 curver = curini.version(submod); - const long curpatch = curini.patch(submod); + const int curpatch = curini.patch(submod); const TString16 reqver = ini.version(submod); - const long reqpatch = ini.patch(submod); + const int reqpatch = ini.patch(submod); int distance = compare_version(reqver, reqpatch, curver, curpatch); upd = distance> 0; - if (!upd) - { - if (distance==0) - ; - else - warning_box("Il sottomodulo '%s' necessario a '%s' e' gia' aggiornato alla versione %s:\n" + if (distance!=0) + warning_box("Il sottomodulo '%s' necessario a '%s' e' gia' aggiornato alla versione %s:\n" "l'installazione della versione %s non verra' effettuata.", (const char*)submod, (const char*)module, (const char*)curver, (const char*)reqver); - } } ok &= move_module(submod, ini, upd); } @@ -575,13 +577,13 @@ bool TInstaller_mask::path_handler(TMask_field& fld, KEY key) bool ok = TRUE; if (key == K_TAB && fld.focusdirty()) { - TString path = fld.get(); + TFilename path = fld.get(); if (path.len() == 2 && isalpha(path[0]) && path[1] == ':') { path << SLASH; fld.set(path); } - if (fexist(path)) + if (path.exist()) _curr_mask->autoload(); else ok = fld.error_box("Specificare un percorso valido"); @@ -597,9 +599,9 @@ void TInstaller_mask::install_selection() { const TString modulo = row->get(2); const TString newver = row->get(3); - const long newpatch = row->get_long(4); + const int newpatch = row->get_int(4); const TString oldver = row->get(6); - const long oldpatch = row->get_long(7); + const int oldpatch = row->get_int(7); if (version2year(newver) < 1997) { @@ -610,16 +612,31 @@ void TInstaller_mask::install_selection() bool ok = TRUE; const int cmp = compare_version(oldver, oldpatch, newver, newpatch); if (cmp < 0) - ok = yesno_box("Si desidera installare la versione %s.%ld?", (const char*)newver, newpatch); + ok = yesno_box("Si desidera installare la versione %s.%d?", (const char*)newver, newpatch); if (cmp == 0) - ok = yesno_box("Si desidera reinstallare la versione %s.%ld?", (const char*)newver, newpatch); + ok = yesno_box("Si desidera reinstallare la versione %s.%d?", (const char*)newver, newpatch); if (cmp > 0) - ok = yesno_box("Si desidera ritornare alla versione %s.%ld?\n" + ok = yesno_box("Si desidera ritornare alla versione %s.%d?\n" "Attenzione: non e' garantito il corretto\n" "funzionamento di tutti i programmi!", (const char*)newver, newpatch); if (ok) - { - install(modulo, newpatch); + { + const bool is_patch = row->get_char(9) > ' '; + ok = install(modulo, is_patch ? newpatch : 0); + if (!is_patch) // Se installo un modulo pricipale ... + { + // ... allora installo tutte le patches + for (int p = r+1; ok; p++) + { + if (row_disabled(p)) + { + const int patchlevel = arr.row(p).get_int(4); + ok = install(modulo, patchlevel); + } + else + break; + } + } } } } @@ -650,7 +667,7 @@ bool TInstaller_mask::on_key(KEY key) TInstaller_mask::TInstaller_mask() : TArray_sheet(0, 0, 0, 0, "Installazione", - "@1|Modulo@30|Cod.|Versione\nda installare@13|Livello\nPatch|Data\nRilascio@10|Versione\nInstallata@10|Livello\nPatch|Data\nInstallazione@13", + "@1|Modulo@30|Cod.|Versione\nda installare@13|Livello\nPatch|Data\nRilascio@10|Versione\nInstallata@10|Livello\nPatch|Data\nInstallazione@13|Aggiornamento", 0x18, 3) { _curr_mask = this; diff --git a/ba/ba1800.cpp b/ba/ba1800.cpp index 1ee6601cc..1aeb81f9b 100755 --- a/ba/ba1800.cpp +++ b/ba/ba1800.cpp @@ -722,6 +722,11 @@ void TWizard_mask::save_ini(const TFilename& ininame) const FOR_EACH_SHEET_ROW(sf, r, row) { ini.set("FIELD", row->get(0), NULL, TRUE, r); + + const char* name = row->get(1); + if (name == NULL || *name <= ' ') + name = row->get(0); + ini.set("NAME", name, NULL, TRUE, r); } } } @@ -762,7 +767,8 @@ bool TWizard_mask::load_aga(const TFilename& name) set(F_RECSEP, "", TRUE); set(F_FIELDSEP, "|", TRUE); set(F_SKIPLINES, aga.linenum(), TRUE); - set(F_ISAM, isam, TRUE); + if (isam.not_empty()) + set(F_ISAM, isam, TRUE); break; } @@ -1022,7 +1028,7 @@ bool TWizard_mask::file_handler(TOperable_field& f, TField_event e) if ((n[0] == 'f' || n[0] == 'F') && atoi(n.mid(1,-1))) n.ltrim(1); if (str2isamfile(n)) - set(F_ISAM, TRUE); + set(F_ISAM, n, TRUE); file_preview(); } @@ -1093,7 +1099,7 @@ bool TWizard_mask::isamfile_handler(TOperable_field& f, TField_event e) fs.describe_fields(); } else - ok = error_box("File non valido"); + ok = error_box("File dati non valido"); can_import &= fexist(get(F_FILE)); enable(F_IMPORT, can_import); reset(F_ZAP); @@ -1199,6 +1205,10 @@ bool TWizard_mask::on_field_event(TOperable_field& f, TField_event e, long jolly if (e == fe_button) import_file(); break; + case F_COLUMNIZER: + if (e == fe_init) + file_preview(); // Indispensabile! + break; case F_FIELDS: ok = ((TFields_sheet&)f).handler(e, jolly); break; diff --git a/ba/ba1800a.uml b/ba/ba1800a.uml index 31743a108..ebef0080d 100755 --- a/ba/ba1800a.uml +++ b/ba/ba1800a.uml @@ -83,7 +83,7 @@ BEGIN PROMPT 41 6 "Azzera il file di destinazione" END -BROWSEFILE F_COLUMNIZER 76 4 +BROWSEFILE F_COLUMNIZER 75 4 BEGIN PROMPT 1 6 "" FLAGS "R" @@ -108,7 +108,7 @@ BEGIN FLAGS "BU" END -STRING F_DESCR 50 +STRING F_DESCR 70 BEGIN PROMPT 1 2 "Descrizione " FLAGS "D" diff --git a/ba/unzip.pif b/ba/unzip.pif new file mode 100755 index 000000000..adc9d161b Binary files /dev/null and b/ba/unzip.pif differ diff --git a/ba/zip.pif b/ba/zip.pif new file mode 100755 index 000000000..ac13ac77e Binary files /dev/null and b/ba/zip.pif differ diff --git a/ba/zip386.bat b/ba/zip386.bat new file mode 100755 index 000000000..84da73a91 --- /dev/null +++ b/ba/zip386.bat @@ -0,0 +1,2 @@ +@echo off +zip386.exe %1 -@ < %2 diff --git a/ba/zipsplit.pif b/ba/zipsplit.pif new file mode 100755 index 000000000..7e04f6eb9 Binary files /dev/null and b/ba/zipsplit.pif differ