Correzioni su fascicolator e sfascicolator

git-svn-id: svn://10.65.10.50/trunk@6008 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1998-01-22 11:56:14 +00:00
parent c617d992bc
commit e9327430fc
5 changed files with 174 additions and 67 deletions

View File

@ -87,6 +87,11 @@ int TInstall_ini::build_complete_list(const TString& module, TString_array& a,
if (submodule.len() > 2) if (submodule.len() > 2)
build_list(submodule, a, sommario, agg); build_list(submodule, a, sommario, agg);
} }
if (sommario && *sommario)
{
TConfig sum(sommario, "Main");
sum.set("Demo", demo());
}
return a.items(); return a.items();
} }
@ -126,6 +131,19 @@ const TString& TInstall_ini::version(const char* module)
return ver; return ver;
} }
long TInstall_ini::patch(const char* module)
{
CHECK(module && *module > ' ', "Can't get version of NULL module");
long patch = get_long("Patch", module);
if (patch == 0 && strlen(module) > 2)
{
TString16 str;
str.strncpy(module, 2);
patch = get_long("Patch", str);
}
return patch;
}
bool TInstall_ini::update_prices(const char* from) bool TInstall_ini::update_prices(const char* from)
{ {
CHECK(fexist(from), "Can't find listino prezzi"); CHECK(fexist(from), "Can't find listino prezzi");
@ -155,37 +173,25 @@ bool TInstall_ini::update_prices(const char* from)
void TInstall_ini::prices(const char* module, word users, void TInstall_ini::prices(const char* module, word users,
real& full, real& assist) real& full, real& assist)
{ {
word min_user = 0; real last_pac, last_ass;
TAssoc_array& arr = list_variables(module); full = assist = 0.0;
FOR_EACH_ASSOC_STRING(arr, obj, key, str) for (word u = 1; u <= users; u++)
{ {
const TFixed_string price(key); TAuto_token_string prezzi = get("Prezzo", module, int(u));
if (price.compare("Prezzo", 6, TRUE) == 0) if (prezzi.not_empty())
{ {
const word user = atoi(key+7); last_pac = prezzi.get(0);
if (user >= min_user && user <= users) if (last_pac < 50000.0)
{ last_pac *= 1000.0;
min_user = user; last_ass = prezzi.get();
if (last_ass < 50000.0)
TAuto_token_string tmp = str; last_ass *= 1000.0;
full = tmp.get(0); const int mese = TDate(TODAY).month();
if (full < 50000.0) last_ass = last_ass * (12-mese) / 12;
full *= 1000.0; last_ass.round(-3);
assist = tmp.get();
if (assist < 50000.0)
assist *= 1000.0;
if (user == 1 && users > 1)
{
full *= users;
assist *= users;
}
const int mese = TDate(TODAY).month();
assist = assist * (12-mese) / 12;
assist.round(-3);
}
} }
full += last_pac;
assist += last_ass;
} }
} }
@ -605,6 +611,7 @@ void TModule_mask::save()
const TString module = get(F_MODULE); const TString module = get(F_MODULE);
const TString version = ini.version(module); const TString version = ini.version(module);
const long patch = ini.patch(module);
for (index = 0; index <= 9; index++) for (index = 0; index <= 9; index++)
{ {
@ -636,6 +643,7 @@ void TModule_mask::save()
if (agg) tmp.add("X"); // Flag aggiornamento if (agg) tmp.add("X"); // Flag aggiornamento
ini.set("File", tmp, sub, TRUE, index++); ini.set("File", tmp, sub, TRUE, index++);
ini.set("Versione", version); // Aggiorna versione del sottomodulo ini.set("Versione", version); // Aggiorna versione del sottomodulo
ini.set("Patch", patch);
} }
} }
} }
@ -672,7 +680,7 @@ protected:
bool zip_file(const char* archive, const char* file) const; bool zip_file(const char* archive, const char* file) const;
int split_file(const TFilename& file, long size) const; int split_file(const TFilename& file, long size) const;
bool move_file(const TFilename& file, const char* dir) const; bool move_file(const TFilename& file, const char* dir) const;
bool zip_module(const TString& module, bool agg) const; bool zip_module(const TString& module, int patch_level, bool agg) const;
const TFilename& build_export_path(TFilename& path) const; const TFilename& build_export_path(TFilename& path) const;
@ -719,14 +727,16 @@ bool TFascicolator_mask::save_handler(TMask_field& f, KEY k)
TInstall_ini ini; TInstall_ini ini;
ini.set_paragraph(module); ini.set_paragraph(module);
ini.set("Versione", m.get(S_VERSION)); ini.set("Versione", m.get(S_VERSION));
ini.set("Patch", m.get(S_PATCHLEVEL));
ini.set("Data", m.get(S_DATE)); ini.set("Data", m.get(S_DATE));
ini.set("Moduli", m.get(S_EXTERN)); ini.set("Moduli", m.get(S_EXTERN));
ini.set("PreProcess", m.get(S_PREPROCESS)); ini.set("PreProcess", m.get(S_PREPROCESS));
ini.set("PostProcess", m.get(S_POSTPROCESS)); ini.set("PostProcess", m.get(S_POSTPROCESS));
} }
const int patch_level = m.get_int(S_PATCHLEVEL);
const bool agg = f.dlg() == S_SAVEAGG; const bool agg = f.dlg() == S_SAVEAGG;
TFascicolator_mask& fm = (TFascicolator_mask&)m.get_sheet()->mask(); TFascicolator_mask& fm = (TFascicolator_mask&)m.get_sheet()->mask();
fm.zip_module(module, agg); fm.zip_module(module, patch_level, agg);
} }
return TRUE; return TRUE;
} }
@ -844,6 +854,9 @@ void TFascicolator_mask::load()
tmp = ini.get("Versione"); tmp = ini.get("Versione");
row.add(tmp); row.add(tmp);
tmp = ini.get("Patch");
row.add(tmp);
tmp = ini.get("Data"); tmp = ini.get("Data");
row.add(tmp); row.add(tmp);
@ -886,6 +899,9 @@ void TFascicolator_mask::save()
tmp = row->get(2); tmp = row->get(2);
ini.set("Versione", tmp); ini.set("Versione", tmp);
tmp = row->get();
ini.set("Patch", tmp);
tmp = row->get(); tmp = row->get();
ini.set("Data", tmp); ini.set("Data", tmp);
@ -993,7 +1009,7 @@ int TFascicolator_mask::split_file(const TFilename& archive, long size) const
TFilename cmd; TFilename cmd;
xvt_fsys_convert_dir_to_str(&curdir, cmd.get_buffer(), cmd.size()); xvt_fsys_convert_dir_to_str(&curdir, cmd.get_buffer(), cmd.size());
cmd.add("zipsplit.pif"); cmd.add("zipsplit.pif");
cmd << " -n " << size << " " << " -b " << archive.path() << " " << archive; cmd << " -n " << size << " -b " << archive.path() << " " << archive;
// Salta alla directory temporanea // Salta alla directory temporanea
xvt_fsys_convert_str_to_dir((char*)archive.path(), &tmpdir); xvt_fsys_convert_str_to_dir((char*)archive.path(), &tmpdir);
@ -1035,14 +1051,21 @@ int TFascicolator_mask::split_file(const TFilename& archive, long size) const
return disks; return disks;
} }
bool TFascicolator_mask::zip_module(const TString& main_module, bool agg) const bool TFascicolator_mask::zip_module(const TString& main_module, int patch_level, bool agg) const
{ {
TString_array arr; TString_array arr;
TInstall_ini ini; TInstall_ini ini;
TFilename sommario; sommario.tempdir(); TFilename sommario; sommario.tempdir();
sommario.add(main_module); sommario.add(main_module);
sommario << "inst.ini"; // Nome del file sommario completo if (agg)
{
TString16 name;
name.format("%03da.ini", patch_level);
sommario << name; // Nome del file sommario aggiornamento
}
else
sommario << "inst.ini"; // Nome del file sommario completo
ini.build_complete_list(main_module, arr, sommario, agg); ini.build_complete_list(main_module, arr, sommario, agg);
if (arr.items() == 0) if (arr.items() == 0)
@ -1063,7 +1086,7 @@ bool TFascicolator_mask::zip_module(const TString& main_module, bool agg) const
FILE * fileh=fopen((const char *)filelist,"w"); FILE * fileh=fopen((const char *)filelist,"w");
TProgind pi(arr.items(), msg, TRUE, TRUE); TProgind pi(arr.items(), msg, TRUE, TRUE);
TString cmd(120); TString cmd(120);
FOR_EACH_ARRAY_ROW_BACK(arr, i, row) FOR_EACH_ARRAY_ROW_BACK(arr, i, row)
{ {
pi.addstatus(1); pi.addstatus(1);
@ -1072,12 +1095,12 @@ bool TFascicolator_mask::zip_module(const TString& main_module, bool agg) const
aborted = TRUE; aborted = TRUE;
break; break;
} }
cmd = row->get(0);
// Se non trovo anche uno solo dei files nella lista, è un casino // Se non trovo anche uno solo dei files nella lista, è un casino
if (_access(row->get(0),0)) if (!fexist(cmd))
{ {
TString msg(128); TString msg(128);
msg << "Impossibile aprire il file " << row->get(0) << ". Interrompo ?"; msg << "Impossibile aprire il file " << cmd << ". Interrompere?";
if (yesno_box(msg)) if (yesno_box(msg))
{ {
aborted = TRUE; aborted = TRUE;
@ -1086,9 +1109,9 @@ bool TFascicolator_mask::zip_module(const TString& main_module, bool agg) const
} }
// Aggiungo il nome corrente alla lista dei files da compattare // Aggiungo il nome corrente alla lista dei files da compattare
cmd=row->get(0);
cmd << '\n'; cmd << '\n';
fwrite(cmd, sizeof(char), cmd.len(),fileh); // fwrite(cmd, sizeof(char), cmd.len(),fileh);
fputs(cmd, fileh);
} }
fclose(fileh); fclose(fileh);
@ -1098,7 +1121,6 @@ bool TFascicolator_mask::zip_module(const TString& main_module, bool agg) const
// elimna il file lista-file // elimna il file lista-file
fileh = fopen((const char *)filelist,"w"); fileh = fopen((const char *)filelist,"w");
fclose(fileh); fclose(fileh);
msg.cut(0); msg.cut(0);
msg << "Separazione del file " << archivio << " ..."; msg << "Separazione del file " << archivio << " ...";

View File

@ -18,6 +18,7 @@ public:
bool demo() { return get_bool("Demo", "Main"); } bool demo() { return get_bool("Demo", "Main"); }
const TString& version(const char* module); const TString& version(const char* module);
long patch(const char* module);
bool update_prices(const char* src_ini); bool update_prices(const char* src_ini);
void prices(const char* module, word users, real& full, real& manut); void prices(const char* module, word users, real& full, real& manut);

View File

@ -11,10 +11,11 @@
#define S_FILE 101 #define S_FILE 101
#define S_MODULE 102 #define S_MODULE 102
#define S_VERSION 103 #define S_VERSION 103
#define S_DATE 104 #define S_PATCHLEVEL 104
#define S_EXTERN 105 #define S_DATE 105
#define S_PREPROCESS 106 #define S_EXTERN 106
#define S_POSTPROCESS 107 #define S_PREPROCESS 107
#define S_POSTPROCESS 108
#define S_LIST 100 #define S_LIST 100
#define S_SAVE 151 #define S_SAVE 151

View File

@ -37,6 +37,7 @@ BEGIN
ITEM "Modulo@30" ITEM "Modulo@30"
ITEM "Cod." ITEM "Cod."
ITEM "Versione" ITEM "Versione"
ITEM "Patch"
ITEM "Rilascio" ITEM "Rilascio"
ITEM "Moduli esterni@30" ITEM "Moduli esterni@30"
ITEM "Pre-processing@25" ITEM "Pre-processing@25"
@ -61,11 +62,16 @@ BEGIN
FLAGS "D" FLAGS "D"
END END
STRING S_VERSION 6 STRING S_VERSION 8
BEGIN BEGIN
PROMPT 1 2 "Versione " PROMPT 1 2 "Versione "
END END
STRING S_PATCHLEVEL 3
BEGIN
PROMPT 20 2 "Patch "
END
DATE S_DATE DATE S_DATE
BEGIN BEGIN
PROMPT 31 2 "Rilascio " PROMPT 31 2 "Rilascio "

View File

@ -13,7 +13,7 @@
#include "ba1600.h" #include "ba1600.h"
#include "ba1700a.h" #include "ba1700a.h"
HIDDEN int compare_version(const char* v1, const char* v2) HIDDEN int compare_version(const char* v1, long p1, const char* v2, long p2)
{ {
TString16 ver1(v1), ver2(v2); TString16 ver1(v1), ver2(v2);
ver1.trim(); ver1.trim();
@ -22,7 +22,14 @@ HIDDEN int compare_version(const char* v1, const char* v2)
ver2.trim(); ver2.trim();
if (ver2.len() == 4) if (ver2.len() == 4)
ver2.insert((v2[0] == '9') ? "19" : "20", 0); ver2.insert((v2[0] == '9') ? "19" : "20", 0);
return ver1.compare(ver2, -1, TRUE);
int res = ver1.compare(ver2, -1, TRUE);
if (res == 0)
{
res = p1 == p2 ? 0 : (p1 > p2 ? +1 : -1);
}
return res;
} }
HIDDEN word version2year(const char* v) HIDDEN word version2year(const char* v)
@ -52,6 +59,7 @@ protected:
static bool install_handler(TMask_field& fld, KEY key); 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);
int sort_modules();
void update_version(); void update_version();
bool move_file(const TFilename& file, const char* dir) const; bool move_file(const TFilename& file, const char* dir) const;
@ -66,7 +74,7 @@ protected:
public: public:
bool autoload(); bool autoload();
bool install(const TString& module); bool install(const TString& module, long patch);
TInstaller_mask(); TInstaller_mask();
virtual ~TInstaller_mask(); virtual ~TInstaller_mask();
@ -85,12 +93,52 @@ bool TInstaller_mask::add_module(TConfig& ini, const TString& module)
row.add(ini.get("Descrizione")); row.add(ini.get("Descrizione"));
row.add(module); row.add(module);
row.add(ini.get("Versione")); row.add(ini.get("Versione"));
row.add(ini.get("Patch"));
row.add(ini.get("Data")); row.add(ini.get("Data"));
add(row); add(row);
} }
return ok; return ok;
} }
static int compare_modules(const TObject** o1, const TObject** o2)
{
TToken_string& ts1 = *(TToken_string*)(*o1);
TToken_string& ts2 = *(TToken_string*)(*o2);
int res = 0;
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;
}
int TInstaller_mask::sort_modules()
{
rows_array().TArray::sort(compare_modules);
const int tot = int(items());
TString16 dis, mod;
for (int r = 0; r < tot; r++)
{
mod = row(r).get(2);
if (dis == mod)
{
disable_row(r);
}
else
{
long patch = row(r).get_long(4);
if (patch == 0)
dis = mod;
}
}
return tot;
}
void TInstaller_mask::update_version() void TInstaller_mask::update_version()
{ {
TInstall_ini ini; TInstall_ini ini;
@ -103,8 +151,9 @@ void TInstaller_mask::update_version()
const TString16 newver = row->get(3); const TString16 newver = row->get(3);
const TString16 oldver = ini.get("Versione"); const TString16 oldver = ini.get("Versione");
row->add(oldver, 5); row->add(oldver, 6);
row->add(ini.get("Data"), 6); row->add(ini.get("Patch"), 7);
row->add(ini.get("Data"), 8);
} }
force_update(); force_update();
} }
@ -148,15 +197,29 @@ bool TInstaller_mask::autoload()
TString& ininame = *row; TString& ininame = *row;
ininame.lower(); ininame.lower();
const int pos = ininame.find("inst.ini"); const int pos = ininame.find("inst.ini");
CHECKS(pos > 2, "Invalid installation configuration: ", (const char*)ininame); CHECKS(pos >= 2, "Invalid installation configuration: ", (const char*)ininame);
const TString16 module = ininame.mid(pos-2, 2); const TString16 module = ininame.mid(pos-2, 2);
TConfig ini(ininame, module); TConfig ini(ininame, module);
add_module(ini, module); add_module(ini, module);
} }
ininame = path;
ininame.add("??0??a.ini");
modules.destroy();
list_files(ininame, modules);
FOR_EACH_ARRAY_ROW(modules, am, arow)
{
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);
TConfig ini(ininame, module);
add_module(ini, module);
}
} }
rows_array().sort(); const bool ok = sort_modules() > 0;
const bool ok = items() > 0;
if (ok) if (ok)
update_version(); update_version();
else else
@ -238,7 +301,7 @@ bool TInstaller_mask::can_install(const char* module, TInstall_ini& ini)
<< "':\nSi desidera procedere alla sua installazione?"; << "':\nSi desidera procedere alla sua installazione?";
ok = yesno_box(msg); ok = yesno_box(msg);
if (ok) if (ok)
ok = install(submodule); ok = install(submodule, 0);
} }
} }
} }
@ -291,7 +354,7 @@ bool TInstaller_mask::move_file(const TFilename& file, const char* dir) const
::remove(file); ::remove(file);
else else
{ {
if (!yesno_box("Errore di copia del file %s.\nSi desidera riprovare?", if (!yesno_box("Errore di copia del file %s.\nSi desidera ritentare?",
(const char*)file)); (const char*)file));
user_abort = TRUE; user_abort = TRUE;
} }
@ -329,14 +392,22 @@ bool TInstaller_mask::move_module(const TString& module, TInstall_ini& ini, bool
return ok; return ok;
} }
bool TInstaller_mask::install(const TString& module) bool TInstaller_mask::install(const TString& module, long patchlevel)
{ {
bool ok = FALSE; bool ok = FALSE;
const TString& path = get(F_PATH); const TString& path = get(F_PATH);
TFilename ininame = path; TFilename ininame = path;
ininame.add(module); ininame.add(module);
ininame << "inst.ini";
if (patchlevel > 0)
{
TString16 name;
name.format("%03da.ini");
ininame << name;
}
else
ininame << "inst.ini";
if (fexist(ininame)) if (fexist(ininame))
{ {
@ -422,8 +493,10 @@ bool TInstaller_mask::install(const TString& module)
{ {
TInstall_ini curini; TInstall_ini curini;
const TString16 curver = curini.version(submod); const TString16 curver = curini.version(submod);
const long curpatch = curini.patch(submod);
const TString16 reqver = ini.version(submod); const TString16 reqver = ini.version(submod);
int distance =compare_version(reqver, curver) ; const long reqpatch = ini.patch(submod);
int distance = compare_version(reqver, reqpatch, curver, curpatch);
upd = distance> 0; upd = distance> 0;
if (!upd) if (!upd)
{ {
@ -526,7 +599,9 @@ void TInstaller_mask::install_selection()
{ {
const TString modulo = row->get(2); const TString modulo = row->get(2);
const TString newver = row->get(3); const TString newver = row->get(3);
const TString oldver = row->get(5); const long newpatch = row->get_long(4);
const TString oldver = row->get(6);
const long oldpatch = row->get_long(7);
if (version2year(newver) < 1997) if (version2year(newver) < 1997)
{ {
@ -535,17 +610,19 @@ void TInstaller_mask::install_selection()
} }
bool ok = TRUE; bool ok = TRUE;
const int cmp = compare_version(oldver, newver); const int cmp = compare_version(oldver, oldpatch, newver, newpatch);
if (cmp < 0) if (cmp < 0)
ok = yesno_box("Si desidera installare la versione %s?", (const char*)newver); ok = yesno_box("Si desidera installare la versione %s.%ld?", (const char*)newver, newpatch);
if (cmp == 0) if (cmp == 0)
ok = yesno_box("Si desidera reinstallare la versione %s?", (const char*)newver); ok = yesno_box("Si desidera reinstallare la versione %s.%ld?", (const char*)newver, newpatch);
if (cmp > 0) if (cmp > 0)
ok = yesno_box("Si desidera ritornare alla versione %s?\n" ok = yesno_box("Si desidera ritornare alla versione %s.%ld?\n"
"Attenzione: non e' garantito il corretto\n" "Attenzione: non e' garantito il corretto\n"
"funzionamento di tutti i programmi!", (const char*)oldver); "funzionamento di tutti i programmi!", (const char*)newver, newpatch);
if (ok) if (ok)
install(modulo); {
install(modulo, newpatch);
}
} }
} }
@ -575,7 +652,7 @@ bool TInstaller_mask::on_key(KEY key)
TInstaller_mask::TInstaller_mask() TInstaller_mask::TInstaller_mask()
: TArray_sheet(0, 0, 0, 0, "Installazione", : TArray_sheet(0, 0, 0, 0, "Installazione",
"@1|Modulo@30|Cod.|Versione\nda installare@13|Data\nRilascio@10|Versione\nInstallata@10|Data\nInstallazione@13", "@1|Modulo@30|Cod.|Versione\nda installare@13|Livello\nPatch|Data\nRilascio@10|Versione\nInstallata@10|Livello\nPatch|Data\nInstallazione@13",
0x18, 3) 0x18, 3)
{ {
_curr_mask = this; _curr_mask = this;