From 132452fd50151df09fd87b0bda747d06c37ce25f Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 24 Oct 2002 10:47:49 +0000 Subject: [PATCH] Patch level : Aga 2.0.349 Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione P@rtners 2.0 patch 349 git-svn-id: svn://10.65.10.50/trunk@10573 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ba/ba0.cpp | 6 +- ba/ba1100.cpp | 149 +++--- ba/ba1101.cpp | 5 +- ba/ba1102.cpp | 13 +- ba/ba1200.cpp | 9 +- ba/ba1300.cpp | 24 +- ba/ba1400.cpp | 8 +- ba/ba1500.cpp | 96 ++-- ba/ba1501.cpp | 23 +- ba/ba1600.cpp | 82 +-- ba/ba1700.cpp | 142 +++--- ba/ba1800.cpp | 127 +++-- ba/ba1900.cpp | 6 - ba/ba2100.cpp | 2 +- ba/ba2200.cpp | 52 +- ba/ba2300.cpp | 4 +- ba/ba2400.cpp | 7 +- ba/ba2500.cpp | 42 +- ba/ba2600.cpp | 75 ++- ba/ba3100.cpp | 26 +- ba/ba3200.cpp | 10 +- ba/ba3300.cpp | 41 +- ba/ba3400.cpp | 7 +- ba/ba3500.cpp | 2 +- ba/ba3600.cpp | 50 +- ba/ba3601.cpp | 36 +- ba/ba3700.cpp | 6 +- ba/ba3800.cpp | 164 +++--- ba/ba3900.cpp | 10 +- ba/ba3a00.cpp | 18 +- ba/ba4200.cpp | 159 ++---- ba/ba4300.cpp | 139 ++---- ba/ba4400.cpp | 11 +- ba/ba4500.cpp | 41 +- ba/ba4600.cpp | 19 +- ba/baformed.cpp | 33 +- include/controls.cpp | 4 +- include/diction.cpp | 16 +- include/diction.h | 3 +- include/fraction.cpp | 439 ++++++++++++++++ include/fraction.h | 121 +++++ include/maskfld.cpp | 20 +- include/netsock.cpp | 7 +- include/printer.cpp | 12 +- include/progind.cpp | 35 +- include/real.cpp | 12 + include/real.h | 4 + include/resource.ini | 166 +++++++ include/utility.cpp | 31 ++ include/utility.h | 3 + include/validate.cpp | 2 +- m770/777100.cpp | 16 +- server/authoriz.cpp | 816 ++++++++++++++++++++++++++++++ server/authoriz.dsp | 233 +++++++++ server/baseserv.cpp | 586 ++++++++++++++++++++++ server/baseserv.dsp | 205 ++++++++ server/baseserv.h | 105 ++++ server/coffee.cpp | 81 +++ server/coffee.dsp | 209 ++++++++ server/diction.cpp | 665 ++++++++++++++++++++++--- server/diction.dsp | 209 ++++++++ server/diction.h | 9 +- server/dongle.cpp | 933 +++++++++++++++++++++++++++++++++++ server/dongle.h | 113 +++++ server/example.cpp | 29 ++ server/fastapi.h | 651 ++++++++++++++++++++++++ server/hlapi_c.h | 72 +++ server/lerch.cpp | 247 ++++++++++ server/lerch.dsp | 209 ++++++++ server/lerch.h | 10 + server/server.cpp | 323 ++++-------- server/skeylink.h | 181 +++++++ server/{soap.cpp => xml.cpp} | 204 +++++--- server/{soap.h => xml.h} | 25 +- ve/ve0100.cpp | 6 +- ve/ve0200g.uml | 1 - xi/xi.c | 21 +- xi/xi2.c | 9 +- xi/xilm3.c | 1 - xi/xiport.c | 18 +- xi/xiport.h | 3 +- xi/xiutils.c | 17 + xvaga/oswin32.cpp | 42 ++ xvaga/oswin32.h | 1 + xvaga/xvaga.cpp | 177 ++++++- xvaga/xvt.h | 4 + xvaga/xvt_defs.h | 7 +- 87 files changed, 7592 insertions(+), 1365 deletions(-) create mode 100755 include/fraction.cpp create mode 100755 include/fraction.h create mode 100755 include/resource.ini create mode 100755 server/authoriz.cpp create mode 100755 server/authoriz.dsp create mode 100755 server/baseserv.cpp create mode 100755 server/baseserv.dsp create mode 100755 server/baseserv.h create mode 100755 server/coffee.cpp create mode 100755 server/coffee.dsp create mode 100755 server/diction.dsp create mode 100755 server/dongle.cpp create mode 100755 server/dongle.h create mode 100755 server/example.cpp create mode 100755 server/fastapi.h create mode 100755 server/hlapi_c.h create mode 100755 server/lerch.cpp create mode 100755 server/lerch.dsp create mode 100755 server/lerch.h create mode 100755 server/skeylink.h rename server/{soap.cpp => xml.cpp} (73%) rename server/{soap.h => xml.h} (68%) diff --git a/ba/ba0.cpp b/ba/ba0.cpp index c96a33e85..c23c828d1 100755 --- a/ba/ba0.cpp +++ b/ba/ba0.cpp @@ -489,7 +489,7 @@ COLOR TColor_mask::cid2color(short cid) const COLOR_BLACK, COLOR_WHITE, COLOR_BLACK, COLOR_YELLOW, COLOR_DKGRAY, COLOR_LTGRAY, - COLOR_LTGRAY, COLOR_WHITE, COLOR_GRAY}; + COLOR_LTGRAY, COLOR_WHITE, COLOR_GRAY }; const int i = cid - 101; CHECK(i >= 0 && i < 12, "Invalid color id"); @@ -497,7 +497,7 @@ COLOR TColor_mask::cid2color(short cid) const } /////////////////////////////////////////////////////////// -// Menu mamnagement +// Menu management /////////////////////////////////////////////////////////// static int get_next_string(const char* s, int from, TString& str, char& brace) @@ -1301,7 +1301,7 @@ int TMenu_application::do_level() TImage& image = _menu.image(curr.picture()); - TPicture_mask mask(curr.caption(), -4, -2, &image); + TPicture_mask mask(curr.caption(), -4, -4, &image); CHECK(_mask == NULL, "Two masks are better than one?"); _mask = &mask; diff --git a/ba/ba1100.cpp b/ba/ba1100.cpp index b263e0fe9..54fa91380 100755 --- a/ba/ba1100.cpp +++ b/ba/ba1100.cpp @@ -88,7 +88,7 @@ HIDDEN bool browse_file_handler(TMask_field& f, KEY k) strcpy(fs.creator, "ba1"); xvt_fsys_get_default_dir(&fs.dir); xvt_fsys_save_dir(); - if (xvt_dm_post_file_open(&fs, "Selezione file") == FL_OK) + if (xvt_dm_post_file_open(&fs, TR("Selezione file")) == FL_OK) { TFilename n; xvt_fsys_convert_dir_to_str(&fs.dir, n.get_buffer(n.size()), n.size()); @@ -144,10 +144,9 @@ TManutenzione_app::TManutenzione_app() : _browse(NULL), _rec(NULL), _mask(NULL), void TManutenzione_app::do_print(TPrinter & p, TRec_sheet & r) { - const char* table[] = {"", "Alfanumerico", "Intero", "Intero Lungo", - "Reale", "Data", "Intero", "Carattere", - "Booleano", "Intero Zerofilled", - "Intero Lungo Zerofilled","Memo"}; + const char* table[] = {"", TR("Alfanumerico"), TR("Intero"), TR("Intero Lungo"), + TR("Reale"), TR("Data"), TR("Intero"), TR("Carattere"), + TR("Booleano"), TR("Intero Zerofilled"), TR("Intero Lungo Zerofilled"),TR("Memo")}; TPrintrow row; TToken_string s; TParagraph_string d("", 25); @@ -166,18 +165,18 @@ void TManutenzione_app::do_print(TPrinter & p, TRec_sheet & r) row.reset(); if (istab) - row.put(format("Lista tabella %s ", (const char *) tab), 2); + row.put(format(FR("Lista tabella %s "), (const char *) tab), 2); else - row.put(format("Lista tracciato %s (%s)", dir.des(), dir.name()), 2); - row.put("Pag. @#", 69); + row.put(format(FR("Lista tracciato %s (%s)"), dir.des(), dir.name()), 2); + row.put(TR("Pag. @#"), 69); p.setheaderline(2, row); row.reset(); - row.put("Nome", 7); - row.put("Tipo", 18); - row.put("Lun.", 38); - row.put("Dec.", 44); - row.put("Pos.", 48); - row.put("Descrizione", 53); + row.put(TR("Nome"), 7); + row.put(TR("Tipo"), 18); + row.put(TR("Lun."), 38); + row.put(TR("Dec."), 44); + row.put(TR("Pos."), 48); + row.put(TR("Descrizione"), 53); p.setheaderline(4, row); TString riga(78); riga.fill('-'); @@ -223,8 +222,8 @@ void TManutenzione_app::do_print(TPrinter & p, TRec_sheet & r) row.reset(); p.print(row); - row.put("Espressione chiave", 7); - row.put("Duplicabile", 68); + row.put(TR("Espressione chiave"), 7); + row.put(TR("Duplicabile"), 68); p.setheaderline(4, row); if (p.rows_left() < 5) @@ -242,7 +241,7 @@ void TManutenzione_app::do_print(TPrinter & p, TRec_sheet & r) s = rec.keydef(i); row.put(format("%3d", i + 1), 2); row.put(s.get(), 7); - row.put(*s.get() == 'X' ? "Si" : "No", 68); + row.put(*s.get() == 'X' ? TR("Si") : TR("No"), 68); p.print(row); } p.formfeed(); @@ -265,7 +264,7 @@ void TManutenzione_app::print() d.get(LF_DIR); int items = (int)d.eod(); TProgind *pi; - pi = new TProgind(items,"Stampa tracciati record archivi", TRUE, TRUE, 63); + pi = new TProgind(items, TR("Stampa tracciati record archivi"), TRUE, TRUE); pi->setstatus(2); @@ -285,17 +284,20 @@ void TManutenzione_app::print() TString_array list; items = list_files("recdesc/d???.des", list); - pi = new TProgind(items,"Stampa descrizione tabelle", TRUE, TRUE, 63); + pi = new TProgind(items,TR("Stampa descrizione tabelle"), TRUE, TRUE); TString16 tab; for (i = 0; !pi->iscancelled() && i < items; i++) { tab = list.row(i).right(7); tab.cut(3); - TRec_sheet r(4, tab); + if (isalpha(tab[0])) + { + TRec_sheet r(4, tab); + do_print(p, r); + } pi->addstatus(1); - do_print(p, r); } delete pi; } @@ -328,7 +330,7 @@ bool TManutenzione_app::create() // initvar e arrmask TFilename dir(argv(3)); if (!fexist(dir)) { - error_box("Non esiste il direttorio %s", (const char*)dir); + error_box(FR("Non esiste il direttorio %s"), (const char*)dir); return FALSE; } if (c == 5) @@ -349,13 +351,13 @@ bool TManutenzione_app::create() // initvar e arrmask const bool superprassi = user() == ::dongle().administrator(); _mask = new TMask ("ba1100a"); - _browse = new TDir_sheet ("Manutenzione file di sistema", superprassi ? 0xC : 0x8); + _browse = new TDir_sheet (TR("Manutenzione file di sistema"), superprassi ? 0xC : 0x8); if (superprassi) { - _browse->add_button(DLG_INSFILE, "~Inserisci", K_F6); - _browse->add_button(DLG_CONVERT, "~Converti", K_F7); - _browse->add_button(DLG_ADDFILE, "~Aggiungi", K_F8); - TButton_field& butt = ((TMask*)_browse)->add_button(DLG_OTHERFILE, 0, "A~ltri", 0, -1, 9, 2, "", 0, 0); + _browse->add_button(DLG_INSFILE, BR("~Inserisci", 9), K_F6); + _browse->add_button(DLG_CONVERT, BR("~Converti", 9), K_F7); + _browse->add_button(DLG_ADDFILE, BR("~Aggiungi", 9), K_F8); + TButton_field& butt = ((TMask*)_browse)->add_button(DLG_OTHERFILE, 0, BR("A~ltri", 9), 0, -1, 9, 2, "", 0, 0); butt.set_exit_key(K_F5); _mask->enable(-1); // Abilita campi privilegiati } @@ -504,9 +506,9 @@ void TManutenzione_app::dump_trc(const char * dir, const bool des_too, const lon of << flags << '\n'; } - TString s("Scarico dei tracciati standard in "); + TString s(TR("Scarico dei tracciati standard in ")); s << dir; - TProgind p(items ? items : 1, s, FALSE, TRUE, 70); + TProgind p(items ? items : 1, s, FALSE, TRUE); p.setstatus(1); for (int i=2;i<=items;i++) //Salta il primo (dir.gen) { @@ -643,7 +645,7 @@ void TManutenzione_app::edit_riga (long riga_sel, TToken_string& riga) case K_F8: if (!superprassi) { - error_box("Funzione non ammessa per l'utente %s", (const char*)user()); + error_box(FR("Funzione non ammessa per l'utente %s"), (const char*)user()); break; } case K_F7: @@ -748,7 +750,7 @@ void TManutenzione_app::delete_riga () int logicnum = (int)_browse->items(); _browse->dir()->get(logicnum); - if (!yesno_box("Confermare l'eliminzione dell'archivio %s", _browse->dir()->name())) + if (!yesno_box(FR("Confermare l'eliminzione dell'archivio %s"), _browse->dir()->name())) return; _browse->dir()->get(LF_DIR); _browse->dir()->eod()--; @@ -786,7 +788,7 @@ void TManutenzione_app::repair_file(int i) remove(n); n.ext("cdx"); remove(n); n.ext("fpt"); remove(n); - s.format("File n. %d - %s : eliminato file errato", i, (const char *)d.filename()); + s.format(FR("File n. %d - %s : eliminato file errato"), i, (const char *)d.filename()); write_log(s); } else @@ -806,7 +808,7 @@ void TManutenzione_app::repair_file(int i) const int reclen = rec.len(); d.set_len(reclen); d.put(i, _nordir, _sysdirop); - s.format("File n. %d - %s : corretto tracciato da %d a %d bytes", i, (const char *)d.filename(), oldreclen, reclen); + s.format(FR("File n. %d - %s : corretto tracciato da %d a %d bytes"), i, (const char *)d.filename(), oldreclen, reclen); write_log(s); } } @@ -834,12 +836,15 @@ void TManutenzione_app::update_dir() const int update_items = (orig_items < items) ? orig_items : items; TString prompt(128); - prompt = "Aggiornamento direttorio "; - if (is_com) prompt << "comune"; - else prompt << " della ditta " << atol(pref) <<"."; - prompt << " Memoria libera: " << long(os_get_free_memory()/1024) << " Kbytes."; + if (is_com) prompt << TR("Aggiornamento direttorio comune"); + else + { + prompt << TR("Aggiornamento direttorio della ditta "); + prompt << atol(pref) <<"."; + } + prompt << TR(" Memoria libera: ") << long(os_get_free_memory()/1024) << " Kbytes."; - TProgind p(update_items ? update_items : 1, prompt, FALSE, TRUE, 70); + TProgind p(update_items ? update_items : 1, prompt, FALSE, TRUE); p.setstatus(1); for (int i = 2; i <= update_items; i++) @@ -898,7 +903,7 @@ void TManutenzione_app::update_dir() n.ext("fpt"); remove(n); TString s; - s.format("File n. %d - %s : eliminato file non utilizzato", i, (const char *)d.filename()); + s.format(FR("File n. %d - %s : eliminato file non utilizzato"), i, (const char *)d.filename()); write_log(s); } } @@ -916,8 +921,7 @@ void TManutenzione_app::update_dir() TSystemisamfile b(i); int err = b.is_valid(TRUE); if (err == _istrcerr && d.eod() == 0 && - yesno_box("Il tracciato record del file %d e' incoerente:\n" - "Si desidera eliminare il file vuoto %s?", i, d.filename())) + yesno_box(FR("Il tracciato record del file %d e' incoerente:\nSi desidera eliminare il file vuoto %s?"), i, d.filename())) { TFilename n(d.filename()); remove(n); n.ext("cdx"); remove(n); @@ -936,7 +940,7 @@ void TManutenzione_app::update_dir() if (!recover(b, err)) { TString s; - s.format("File n. %d - %s : errore n.ro %d", i, (const char *)d.filename(), err); + s.format(TR("File n. %d - %s : errore n.ro %d"), i, (const char *)d.filename(), err); write_log(s); } } @@ -975,15 +979,6 @@ void TManutenzione_app::update_dir() if (to_create && !cmn_file) { -/* non piu' necessario - if (is_firm) - { - TString name(fd); - fd.cut(0); - fd << fs.path() << name; - } -*/ - if (flags < 10000L && flags > -1L && fexist(fs) && (fd != fs)) { bool ok = TRUE; @@ -1083,17 +1078,12 @@ void TManutenzione_app::update_dir() } if (towrite) d.put(i, _nordir, _sysdirop); -// d.get(i); } // end of for scope -// prefix().set(pref); if (items >= orig_items) return; for (i = items + 1; i <= orig_items; i++) { -// prefix().set(""); -// d.get(i, _nolock, _nordir, _sysdirop); -// prefix().set(pref); TDir d1((TDir &) _dirs[i]); d1.set_len(0); @@ -1126,10 +1116,13 @@ void TManutenzione_app::convert_dir() const int update_items = (orig_items < items) ? orig_items : items; TString s(256); - s = "Aggiornamento archivi "; - if (is_com) s << "comuni."; - else s << "della ditta " << atol (pref) << "."; - s << " Memoria libera: " << long(os_get_free_memory()/1024) << " Kbytes."; + if (is_com) s = TR("Aggiornamento archivi comuni."); + else + { + s = TR("Aggiornamento archivi della ditta "); + s << atol (pref) << "."; + } + s << TR("Memoria libera: ") << long(os_get_free_memory()/1024) << " Kbytes."; TProgind p(update_items ? update_items : 1, s, FALSE, TRUE); p.setstatus(1); @@ -1161,8 +1154,7 @@ void TManutenzione_app::convert_dir() if (err != NOERR) { - if (!yesno_box("Il file %d non puo' essere aperto:\n" - "Errore %d. Continuare ugualmente?",i,err)) + if (!yesno_box(FR("Il file %d non puo' essere aperto:\nErrore %d. Continuare ugualmente?"),i,err)) stop_run(); else continue; @@ -1297,7 +1289,7 @@ void TManutenzione_app::load_des(const int maxfdir) for (int i = last_newln+1; i #include +#include #include #include #include @@ -94,7 +95,7 @@ TRec_sheet::TRec_sheet(int logicnum, const char * tab) FILE * fd = NULL; if (!fexist(_descfname) && (fd = fopen(_descfname, "w")) == NULL) - error_box("Impossibile creare il file delle descrizioni"); + error_box(TR("Impossibile creare il file delle descrizioni")); else { if (fd != NULL) @@ -217,7 +218,7 @@ void TRec_sheet::save() { if ((*_rec == *_rec_old && !_descr) || - !yesnocancel_box("Salvare le modifiche")) return; + !yesnocancel_box(TR("Salvare le modifiche"))) return; if (prefix().name()[0]) // Non fare conversioni sui dati standard { diff --git a/ba/ba1102.cpp b/ba/ba1102.cpp index 75c2d5a46..d7e58951c 100755 --- a/ba/ba1102.cpp +++ b/ba/ba1102.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -48,7 +49,7 @@ bool TEdit_file::_browse(TCursor& cursor, const TFilename& name) { if (!superprassi) { - error_box("Funzione non ammessa per l'utente %s", (const char*)user()); + error_box(FR("Funzione non ammessa per l'utente %s"), (const char*)user()); ch = K_ESC; } @@ -61,7 +62,7 @@ bool TEdit_file::_browse(TCursor& cursor, const TFilename& name) long j; const long items = sheet.items(); const long checked = sheet.checked(); - if (checked && yesno_box("Si desidera cancellare i %ld record indicati?", checked)) + if (checked && yesno_box(FR("Si desidera cancellare i %ld record indicati?"), checked)) { TWait_cursor hourglass; for (j = 0, cursor = 0; j < items; j++) @@ -70,7 +71,7 @@ bool TEdit_file::_browse(TCursor& cursor, const TFilename& name) { if (!pind) { - pind = new TProgind(sheet.checked(),"Attendere...", TRUE, TRUE, 32); + pind = new TProgind(sheet.checked(),TR("Attendere..."), TRUE, TRUE); pind->addstatus(1); } else @@ -118,7 +119,7 @@ bool TEdit_file::_browse(TCursor& cursor, const TFilename& name) } break; case K_DEL: // delete record - if (yesno_box("Confermare la cancellazione del record")) + if (yesno_box(TR("Confermare la cancellazione del record"))) cursor.file().remove(); break; case K_INS: // insert new record @@ -141,7 +142,7 @@ bool TEdit_file::browse(int logicnum, const TFilename& name, const TString& tab) TSystemisamfile test(logicnum); int err = test.open_ex(); if (err != NOERR) - return error_box("Impossibile aprire il file %d: errore %d", logicnum, err); + return error_box(FR("Impossibile aprire il file %d: errore %d"), logicnum, err); test.close(); } @@ -175,7 +176,7 @@ KEY TEdit_file::edit_record(TRectype& rec, bool readonly) const int fpp = 16; // Fields per page const int rows = recs > fpp ? 20 : recs+4; const int pages = recs/fpp + (recs % fpp ? 1 : 0); - TMask m("Modifica record", pages, 78, rows); + TMask m(TR("Modifica record"), pages, 78, rows); if (pages > 1) m.add_default_tag_buttons(); int curpage = 0, currow = 1, nid = 100; diff --git a/ba/ba1200.cpp b/ba/ba1200.cpp index 1ab4c0b55..e8a651639 100755 --- a/ba/ba1200.cpp +++ b/ba/ba1200.cpp @@ -11,12 +11,7 @@ class TTest_application : public TSkeleton_application { protected: - bool create() { dispatch_e_menu(BAR_ITEM(1)); return TSkeleton_application::create(); } - bool destroy() { return TRUE; } virtual void main_loop(); - -public: - TTest_application() {} }; void TTest_application::main_loop() @@ -28,7 +23,7 @@ void TTest_application::main_loop() TRecnotype r = 1; TString80 msg; { - TProgind p(n, "Lettura file comuni", TRUE, TRUE, 32); + TProgind p(n, TR("Lettura file comuni"), TRUE, TRUE); start = clock(); for (tab.first(); tab.good(); tab.next(), r++) { @@ -52,7 +47,7 @@ void TTest_application::main_loop() int ba1200(int argc, char** argv) { TTest_application a; - a.run(argc, argv, "Test File"); + a.run(argc, argv, TR("Test File")); return 0; } diff --git a/ba/ba1300.cpp b/ba/ba1300.cpp index 60b74f000..c1946df86 100755 --- a/ba/ba1300.cpp +++ b/ba/ba1300.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -31,10 +32,10 @@ bool TPackFiles_application::create() // initvar e arrmask if (!set_firm()) return FALSE; const bool is_prassi = user() == ::dongle().administrator(); - _selsheet = new TArray_sheet(-1, -1, -4, -4, "Selezione files", + _selsheet = new TArray_sheet(-1, -1, -4, -4, TR("Selezione files"), is_prassi ? - "@1|N.@5|Nome@20|EOD@7|EOX@7|Lung. |Descrizione@43|Flags@7" : - "N.@5|Nome@20|EOD@7|EOX@7|Lung. |Descrizione@43|Flags@7", + HR("@1|N.@5|Nome@20|EOD@7|EOX@7|Lung. |Descrizione@43|Flags@7") : + HR("N.@5|Nome@20|EOD@7|EOX@7|Lung. |Descrizione@43|Flags@7"), is_prassi ? 0 : 0x10); return TSkeleton_application::create(); } @@ -111,7 +112,7 @@ void TPackFiles_application::main_loop() TString cmd; TDir d; TDir ds; - TProgind p(items, "Compattazione in corso...", TRUE, TRUE ); + TProgind p(items, TR("Compattazione in corso..."), TRUE, TRUE ); for (long i = 2; i<=items; i++) // Skip LF_DIR { p.setstatus(i); @@ -146,7 +147,7 @@ void TPackFiles_application::main_loop() f.packindex(); status = f.status(); if (status == -60) // Se ritorna -60 allora il file e' aperto da qualcuno - retry = yesno_box("Il file %s non puo' essere compattato perche' aperto da altre applicazioni. Riprovare?",(const char*) f_name); + retry = yesno_box(FR("Il file %s non puo' essere compattato perche' aperto da altre applicazioni. Riprovare?"),(const char*) f_name); } } while (retry); // Ci riprovo ! @@ -158,8 +159,7 @@ void TPackFiles_application::main_loop() continue; // Se il file non esiste e non si ha il modulo abilitato evita inutili controlli } // Se le pack() hanno ritornato -60 ma il file esiste, allora prosegue con il prossimo if (status != NOERR && - yesno_box("Rilevato l'errore %d cercando di compattare il file %s." - " Si desidera scaricarlo e ricaricarlo?",status,(const char*)f_name)) + yesno_box(FR("Rilevato l'errore %d cercando di compattare il file %s. Si desidera scaricarlo e ricaricarlo?"),status,(const char*)f_name)) { // Dump the file, Zap it and Reload it. d_name = ""; @@ -176,17 +176,17 @@ void TPackFiles_application::main_loop() if (f.load(d_name) == NOERR) // Reload unlink(d_name); else - error_box("Impossibile ricaricare %s. Errore %d",(const char*) d_name, f.status()); + error_box(FR("Impossibile ricaricare %s. Errore %d"),(const char*) d_name, f.status()); else - error_box("Impossibile azzerare %s. Errore %d",(const char*) f_name, f.status()); + error_box(FR("Impossibile azzerare %s. Errore %d"),(const char*) f_name, f.status()); } else - error_box("Impossibile scaricare %s. Errore %d",(const char*) d_name, f.status()); + error_box(FR("Impossibile scaricare %s. Errore %d"),(const char*) d_name, f.status()); } } } else - warning_box("Nessun file selezionato"); + warning_box(TR("Nessun file selezionato")); break; default: break; @@ -197,6 +197,6 @@ void TPackFiles_application::main_loop() int ba1300(int argc, char** argv) { TPackFiles_application a; - a.run(argc,argv,"Compatta files"); + a.run(argc,argv,TR("Compatta files")); return 0; } diff --git a/ba/ba1400.cpp b/ba/ba1400.cpp index b786428a7..7b01fc3da 100755 --- a/ba/ba1400.cpp +++ b/ba/ba1400.cpp @@ -377,7 +377,7 @@ TMenu::TMenu(const char* menuname) { TString root; import(menuname, root); - add_son(new TMenu_node("Menu Principale")); + add_son(new TMenu_node(TR("Menu Principale"))); add_submenu(root, 0); goto_root(); expand(); @@ -393,7 +393,7 @@ bool TSet_users::user_handler(TMask_field& f, KEY key) return TRUE; const bool ok = f.get().find(' ') < 0; if (!ok) - return f.error_box("Il nome dell'utente non deve contenere spazi"); + return f.error_box(TR("Il nome dell'utente non deve contenere spazi")); return ok; } @@ -785,10 +785,10 @@ int ba1400(int argc, char** argv) if (user() == ::dongle().administrator()) { TSet_users a ; - a.run(argc, argv, "Configurazione utenti"); + a.run(argc, argv, TR("Configurazione utenti")); } else { TSet_user_passwd a ; - a.run(argc, argv, "Configurazione utenti"); + a.run(argc, argv, TR("Configurazione utenti")); } return 0; } diff --git a/ba/ba1500.cpp b/ba/ba1500.cpp index 3284a50f6..40e61dcc2 100755 --- a/ba/ba1500.cpp +++ b/ba/ba1500.cpp @@ -63,7 +63,7 @@ TInformazione_moduli::TInformazione_moduli() } if (in.bad() && !in.eof()) - error_box("Si e' verificato un errore leggendo il file di descrizione moduli."); + error_box(TR("Si e' verificato un errore leggendo il file di descrizione moduli.")); _infos.sort(); for (int i=0;iget(0))) din.activate(module); } else { if (din.active(module) && - yesno_box("Confermare la disattivazione del modulo %d:\n%s", + yesno_box(FR("Confermare la disattivazione del modulo %d:\n%s"), module, riga->get(0))) din.deactivate(module); } @@ -612,7 +612,7 @@ bool TAttivazione_moduli::burn_dongle() { ok = din.burn(); if (!ok) - error_box("Impossibile riprogrammare la chiave"); + error_box(TR("Impossibile riprogrammare la chiave")); } } @@ -632,7 +632,7 @@ bool TAttivazione_moduli::maxuser_handler(TMask_field& fld, KEY key) fld.mask().set(102, str); } else - ok = fld.error_box("Numero di utenti errato"); + ok = fld.error_box(TR("Numero di utenti errato")); } return ok; } @@ -641,9 +641,9 @@ bool TAttivazione_moduli::change_users_handler(TMask_field& fld, KEY key) { if (key == K_SPACE) { - TMask m("Utenti", 1, 40, 5); - m.add_number(101, 0, "Utenti ", 1, 1, 4, "U"); - m.add_string(102, 0, "Codice ", 1, 2, 8, "U"); + TMask m(TR("Utenti"), 1, 40, 5); + m.add_number(101, 0, PR("Utenti "), 1, 1, 4, "U"); + m.add_string(102, 0, PR("Codice "), 1, 2, 8, "U"); m.add_button(DLG_OK, 0, "", -12, -1, 10, 2); m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2); @@ -667,8 +667,7 @@ bool TAttivazione_moduli::change_users_handler(TMask_field& fld, KEY key) { app()._wanted_users = utenti; if (utenti > 0) - fld.message_box("Premere il bottone '%s'\n" - "per richiedere l'attivazione di %d utenti.", + fld.message_box(TR("Premere il bottone '%s'\nper richiedere l'attivazione di %d utenti."), fld.mask().field(F_PRINT).prompt(), utenti); } else @@ -681,11 +680,11 @@ bool TAttivazione_moduli::change_users_handler(TMask_field& fld, KEY key) fld.mask().set(F_USERS, utenti); } else - fld.error_box("Codice errato"); + fld.error_box(TR("Codice errato")); } } else - fld.error_box("Numero di utenti errato"); + fld.error_box(TR("Numero di utenti errato")); } else app()._wanted_users = utenti; @@ -707,7 +706,7 @@ bool TAttivazione_moduli::assist_handler(TMask_field& fld, KEY key) fld.mask().set(102, str); } else - ok = fld.error_box("Anno errato"); + ok = fld.error_box(TR("Anno errato")); } return ok; } @@ -716,9 +715,9 @@ bool TAttivazione_moduli::change_assist_handler(TMask_field& fld, KEY key) { if (key == K_SPACE) { - TMask m("Assistenza", 1, 40, 5); - m.add_number(101, 0, "Anno ", 1, 1, 4, "U"); - m.add_string(102, 0, "Codice ", 1, 2, 8, "U"); + TMask m(TR("Assistenza"), 1, 40, 5); + m.add_number(101, 0, PR("Anno "), 1, 1, 4, "U"); + m.add_string(102, 0, PR("Codice "), 1, 2, 8, "U"); m.add_button(DLG_OK, 0, "", -12, -1, 10, 2); m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2); @@ -741,8 +740,7 @@ bool TAttivazione_moduli::change_assist_handler(TMask_field& fld, KEY key) if (m.field(102).empty()) { app()._wanted_assist = year; - fld.message_box("Premere il bottone '%s'\n" - "per rinnovare il contratto di assistenza per l'anno %u.", + fld.message_box(FR("Premere il bottone '%s'\nper rinnovare il contratto di assistenza per l'anno %u."), fld.mask().field(F_PRINT).prompt(), year); } else @@ -758,11 +756,11 @@ bool TAttivazione_moduli::change_assist_handler(TMask_field& fld, KEY key) fld.mask().set(F_ASSIST, year); } else - fld.error_box("Codice errato"); + fld.error_box(TR("Codice errato")); } } else - fld.error_box("Anno errato"); + fld.error_box(TR("Anno errato")); } else app()._wanted_assist = year; @@ -790,10 +788,10 @@ bool TAttivazione_moduli::aga_handler(TMask_field& fld, KEY key) { if (key == K_SPACE) { - TMask mask("Produttore", 1, 50, 6); - mask.add_string(101, 0, "Ditta ", 1, 1, 40); - mask.add_string(102, 0, "Amministratore di sistema ", 1, 2, 8, "U"); - mask.add_string(103, 0, "Password di amministratore ", 1, 3, 8, "*"); + TMask mask(TR("Produttore"), 1, 50, 6); + mask.add_string(101, 0, PR("Ditta "), 1, 1, 40); + mask.add_string(102, 0, PR("Amministratore di sistema "), 1, 2, 8, "U"); + mask.add_string(103, 0, PR("Password di amministratore "), 1, 3, 8, "*"); mask.add_button(DLG_OK, 0, "", -12, -1, 10, 2); mask.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2); @@ -830,7 +828,7 @@ void TAttivazione_moduli::init_mask() garble(ud); _msk->set(F_K1, format("%04X%04X%04X%04X", ud[0], ud[1], ud[2], ud[3])); - _msk->set_caption("Attivazione HARDLOCK"); + _msk->set_caption(TR("Attivazione HARDLOCK")); } else { @@ -838,7 +836,7 @@ void TAttivazione_moduli::init_mask() _msk->hide(F_K2); _msk->hide(F_K3); _msk->hide(F_K4); - _msk->set_caption("Attivazione EUTRON"); + _msk->set_caption(TR("Attivazione EUTRON")); } _msk->set(F_SN, ::dongle().number()); @@ -885,12 +883,12 @@ bool TAttivazione_moduli::user_hnd(TMask_field & f, KEY k) d.addmonth(3); if (d < d1) { - f.error_box("Data non valida"); + f.error_box(TR("Data non valida")); return k != K_ENTER; } if ((ud1[2] & UBYTEMASK) != K1 || ud1[3] != app().serno()) { - f.error_box("Primo codice errato"); + f.error_box(TR("Primo codice errato")); return k != K_ENTER; } @@ -898,7 +896,7 @@ bool TAttivazione_moduli::user_hnd(TMask_field & f, KEY k) for (int i = 0; i < 4; i++) ud2[i] ^= app().serno(); if (ud2[3] != 0) { - f.error_box("Secondo codice errato"); + f.error_box(TR("Secondo codice errato")); return k != K_ENTER; } TSheet_field& sf = (TSheet_field&) m.field(F_MODULI); @@ -914,7 +912,7 @@ bool TAttivazione_moduli::user_hnd(TMask_field & f, KEY k) { keyext(k4, ud2); if (::dongle().write_words(48, 4, ud2)) - message_box("Programmazione effettuata con successo"); + message_box(TR("Programmazione effettuata con successo")); } else sf.force_update(); @@ -937,15 +935,15 @@ bool TAttivazione_moduli::date_hnd(TMask_field& f, KEY k) const TDate data(f.get()); const TDate oggi(TODAY); if (data > oggi) - return f.error_box("La data deve essere antecedente a quella di sistema"); + return f.error_box(FR("La data deve essere antecedente a quella di sistema")); const TDate& last_update = ::dongle().last_update(); if (data < last_update) - return f.error_box("La data deve essere successiva al %s", last_update.string()); + return f.error_box(FR("La data deve essere successiva al %s"), last_update.string()); const int year_assist = ::dongle().year_assist()+1; if (data.year() > year_assist) - return f.error_box("La data deve essere antecedente al 31-12-%d", year_assist); + return f.error_box(FR("La data deve essere antecedente al 31-12-%d"), year_assist); } return TRUE; } @@ -1004,12 +1002,12 @@ bool TAttivazione_moduli::decode_hnd(TMask_field & f, KEY k) const TDate d(l); app().serno() = ud1[0]; if ((ud1[1] & UBYTEMASK) != K1) - return f.error_box("primo codice errato"); + return f.error_box(TR("Primo codice errato")); app().garble(ud2); for (int i = 0; i < 4; i++) ud2[i] ^= app().serno(); if (ud2[3] != 0) - return f.error_box("secondo codice errato"); + return f.error_box(TR("Secondo codice errato")); m.set(F_SN, app().serno()); m.set(F_DT, d); m.set(F_K3,k1); @@ -1061,8 +1059,8 @@ bool TAttivazione_moduli::aggiorna_listino_handler(TMask_field& fld, KEY key) name.add(ini.default_name()); while (!name.exist()) { - TMask msk("Aggiornamento listino", 1, -1, -1, 60, 4); - msk.add_string(DLG_USER, 0, "Percorso ", 1, 1, 50); + TMask msk(TR("Aggiornamento listino"), 1, -1, -1, 60, 4); + msk.add_string(DLG_USER, 0, PR("Percorso "), 1, 1, 50); msk.add_button(DLG_CANCEL, 0, "", -12, -1, 10, 2); msk.add_button(DLG_OK, 0, "", -22, -1, 10, 2); msk.set(DLG_USER, name); @@ -1077,9 +1075,9 @@ bool TAttivazione_moduli::aggiorna_listino_handler(TMask_field& fld, KEY key) if (ok) { if (ok = ini.update_prices(name)) - message_box("Listino aggiornato"); + message_box(TR("Listino aggiornato")); else - message_box("Listino già aggiornato"); + message_box(TR("Listino già aggiornato")); } } return ok; @@ -1146,7 +1144,7 @@ void TAttivazione_moduli::print_request() str = row->get(0); descr.set(str); - str = active ? "*ATTIVO*" : ""; + str = active ? TR("*ATTIVO*") : ""; codice.set(str); str = _im->get_name(module); @@ -1178,7 +1176,7 @@ void TAttivazione_moduli::print_request() str.format("%3d", ++found); num.set(str); - str.format("Variazione del numero utenti da %u a %u", + str.format(FR("Variazione del numero utenti da %u a %u"), ::dongle().max_users(), _wanted_users); descr.set(str); form.print(-1); @@ -1187,7 +1185,7 @@ void TAttivazione_moduli::print_request() { str.format("%3d", ++found); num.set(str); - str.format("Contratto di assistenza per l'anno %u", _wanted_assist); + str.format(FR("Contratto di assistenza per l'anno %u"), _wanted_assist); descr.set(str); form.print(-1); } @@ -1226,7 +1224,7 @@ void TAttivazione_moduli::print_status() continue; descr.set(row->get(0)); - codice.set("*ATTIVO*"); + codice.set(TR("*ATTIVO*")); form.print(-1); } @@ -1282,7 +1280,7 @@ void TAttivazione_moduli::print_answer() { str.format("%3d", ++found); num.set(str); - str.format("Variazione del numero utenti da %u a %u", + str.format(FR("Variazione del numero utenti da %u a %u"), ::dongle().max_users(), _wanted_users); descr.set(str); garble_user(_wanted_users, str); @@ -1293,7 +1291,7 @@ void TAttivazione_moduli::print_answer() { str.format("%3d", ++found); num.set(str); - str.format("Contratto di assistenza per l'anno %u", _wanted_assist); + str.format(FR("Contratto di assistenza per l'anno %u"), _wanted_assist); descr.set(str); garble_year(_wanted_assist, str); codice.set(str); @@ -1343,10 +1341,10 @@ void TAttivazione_moduli::print_listino() if (found++ == 0) { printer().open(); - form.find_field('H',odd_page,1).set("LISTINO"); + form.find_field('H',odd_page,1).set(TR("LISTINO")); num.set(""); - str.format("Numero utenti: %u", users ); + str.format(TR("Numero utenti: %u"), users ); descr.set(str); form.print(-1); } @@ -1539,9 +1537,9 @@ int ba1500(int argc, char** argv) if (user() == ::dongle().administrator()) { TAttivazione_moduli a ; - a.run(argc, argv, "Attivazione moduli"); + a.run(argc, argv, FR("Attivazione moduli")); } else - error_box("L'utente %s non e' abilitato all'esecuzione di questo programma", (const char*)user()); + error_box(FR("L'utente %s non e' abilitato all'esecuzione di questo programma"), (const char*)user()); return 0; } diff --git a/ba/ba1501.cpp b/ba/ba1501.cpp index 36de7c0b8..a5d5fea27 100755 --- a/ba/ba1501.cpp +++ b/ba/ba1501.cpp @@ -77,7 +77,7 @@ HIDDEN bool show_error(const char* str) TApplication::get_version_info(app_year, dum1, dum2, dum3); TString msg; - msg << "Impossibile aggiornare automaticamente l'assistenza " + msg << TR("Impossibile aggiornare automaticamente l'assistenza ") << app_year << ":\n" << str << '.'; return error_box(msg); } @@ -115,7 +115,7 @@ bool update_dninst(bool force) TConfig ini("install.ini", "Main"); TFilename remote_name = ini.get("DiskPath"); if (os_is_removable_drive(remote_name)) - message_box("Assicuratevi che il CD di installazione sia nel lettore %c:", remote_name[0]); + message_box(FR("Assicuratevi che il CD di installazione sia nel lettore %c:"), remote_name[0]); remote_name.add(keys_name); if (remote_name.exist()) fcopy(remote_name, keys_name); @@ -154,33 +154,22 @@ bool update_assistance_year() sn = atoi(line); if (sn == serno) { -/* - TToken_string moduli(line, ';'); - TString8 mod; - FOR_EACH_TOKEN(moduli, tok) - { - mod = tok; - const int nmod = module2number(mod); - if (nmod > 0) - dongle().deactivate(nmod); - } -*/ dongle().set_year_assist(ass_year); if (dongle().burn()) { - message_box("Il contratto %d è stato attivato automaticamente", ass_year); + message_box(FR("Il contratto %d è stato attivato automaticamente"), ass_year); return TRUE; } else { - show_error("errore di scrittura sulla chiave di protezione"); + show_error(FR("errore di scrittura sulla chiave di protezione")); return FALSE; } } } - show_error("il numero di serie di questa postazione non è presente sul database"); + show_error(TR("Il numero di serie di questa postazione non è presente sul database")); } else - show_error("il database dei numeri di serie non è accessibile"); + show_error(TR("Il database dei numeri di serie non è accessibile")); return FALSE; } diff --git a/ba/ba1600.cpp b/ba/ba1600.cpp index b456e2902..09af732c5 100755 --- a/ba/ba1600.cpp +++ b/ba/ba1600.cpp @@ -527,7 +527,7 @@ bool TMod_composition_msk::sheet_notify(TSheet_field& sf, int r, KEY key) } } else - ok = sf.error_box("Nessun file corrisponde a %s", mask.get_buffer()); + ok = sf.error_box(FR("Nessun file corrisponde a %s"), mask.get_buffer()); } } break; @@ -597,7 +597,7 @@ bool TMod_composition_msk::file_handler(TMask_field& f, KEY k) strcpy(fs.name, "*.*"); strcpy(fs.creator, "SETUP"); - FL_STATUS ok = xvt_dm_post_file_open(&fs, "Selezionare il file ..."); + FL_STATUS ok = xvt_dm_post_file_open(&fs, TR("Selezionare il file ...")); xvt_fsys_set_dir(&dir); if (ok == FL_OK) @@ -616,7 +616,7 @@ bool TMod_composition_msk::file_handler(TMask_field& f, KEY k) } else { - return f.error_box("Il file deve trovarsi nel percorso %s", + return f.error_box(FR("Il file deve trovarsi nel percorso %s"), start.get_buffer()); } } @@ -690,7 +690,7 @@ bool TMod_composition_msk::isam_handler(TMask_field& f, KEY k) if (k == K_F9) { TMask& m = f.mask(); - TArray_sheet sht(-1,-1,-4,-4,"Selezione archivio", "Codice@6R|Descrizione archivio@70"); + TArray_sheet sht(-1,-1,-4,-4,TR("Selezione archivio"), HR("Codice@6R|Descrizione archivio@70")); const TPrefix& pref = prefix(); const int total = pref.items(); if (total > 0) @@ -1036,7 +1036,7 @@ bool TModule_mask::check_patchlevels( TMod_composition_msk &mm) if (version == sub_ver) { if ( patchlev > sub_patch - && yesno_box("Il modulo '%s' dipende dal sottomodulo '%s'.\n Aggiorno il suo numero di patch a %d ?",(const char *)mod_code,(const char *)sub_mod,patchlev)) + && yesno_box(FR("Il modulo '%s' dipende dal sottomodulo '%s'.\n Aggiorno il suo numero di patch a %d ?"),(const char *)mod_code,(const char *)sub_mod,patchlev)) { curr_row.add(patchlev , modsheet.cid2index(S_PATCHLEVEL)); curr_row.add(get(S_DATE) , modsheet.cid2index(S_DATE)); @@ -1044,7 +1044,7 @@ bool TModule_mask::check_patchlevels( TMod_composition_msk &mm) } } else if (!sub_ver.blank()) - warning_box("Il modulo '%s', dipendente dal sottomodulo '%s' \nha codice di release %s", + warning_box(FR("Il modulo '%s', dipendente dal sottomodulo '%s' \nha codice di release %s"), (const char *)mod_code, (const char *)sub_mod,(const char *)sub_ver); } else if (module_dependent(midx,submodules, sub_mod, sub_ver, sub_patch)) @@ -1052,7 +1052,7 @@ bool TModule_mask::check_patchlevels( TMod_composition_msk &mm) if (version == sub_ver) { if ( patchlev > sub_patch - && noyes_box("Il modulo '%s' dipende da sottomoduli del modulo '%s'.\n Aggiorno il suo numero di patch a %d ?",(const char *)mod_code,(const char *)module,patchlev)) + && noyes_box(FR("Il modulo '%s' dipende da sottomoduli del modulo '%s'.\n Aggiorno il suo numero di patch a %d ?"),(const char *)mod_code,(const char *)module,patchlev)) { curr_row.add(patchlev , modsheet.cid2index(S_PATCHLEVEL)); curr_row.add(get(S_DATE) , modsheet.cid2index(S_DATE)); @@ -1060,7 +1060,7 @@ bool TModule_mask::check_patchlevels( TMod_composition_msk &mm) } } else if (!sub_ver.blank()) - warning_box("Il modulo '%s', dipendente da sottomoduli del modulo '%s'\nha codice di release %s", + warning_box(FR("Il modulo '%s', dipendente da sottomoduli del modulo '%s'\nha codice di release %s"), (const char *)mod_code, (const char *)sub_mod,(const char *)sub_ver); } } @@ -1141,7 +1141,7 @@ bool TFascicolator_mask::confirm_handler(TMask_field& f, KEY k) m.field(S_PATCHLEVEL).dirty(); if (dirty_version || dirty_module) { - TIndwin infobar(60,"Salvataggio composizione modulo",FALSE,FALSE); + TIndwin infobar(60,TR("Salvataggio composizione modulo"),FALSE,FALSE); TInstall_ini ini; ini.set_paragraph(module); ini.set("Versione", m.get(S_VERSION)); @@ -1169,7 +1169,7 @@ bool TFascicolator_mask::confirm_handler(TMask_field& f, KEY k) if (patchlevel>0 && (m.list_is_dirty() || dirty_version)) { // controlla le consistenze tra patch di moduli diversi intrinsecamente correlati - TIndwin infobar(60,"Controllo dipendenze tra sottomoduli",FALSE,FALSE); + TIndwin infobar(60,TR("Controllo dipendenze tra sottomoduli"),FALSE,FALSE); TMod_composition_msk mc; mc.load(module); m.check_patchlevels(mc); @@ -1227,10 +1227,10 @@ bool TCreadischi_mask::why_handler(TMask_field& f, KEY k) TString_array inifiles; list_files(path, inifiles); inifiles.sort(); - TProgind pi(inifiles.items(), "Scansione archivi successivi...", FALSE, TRUE); + TProgind pi(inifiles.items(), TR("Scansione archivi successivi..."), FALSE, TRUE); - TString caption; caption << "File eliminabili da " << stopfile.name(); - TArray_sheet sheet(3, 3, -3, -3, caption, "Modulo|File@20|Ultima Patch@50"); + TString caption; caption << TR("File eliminabili da ") << stopfile.name(); + TArray_sheet sheet(3, 3, -3, -3, caption, HR("Modulo|File@20|Ultima Patch@50")); TAssoc_array files; TString_array para; @@ -1264,7 +1264,7 @@ bool TCreadischi_mask::why_handler(TMask_field& f, KEY k) if (nextpatch) row.add(*nextpatch); else - row.add("*** Nessuna ***"); // Should never happen! + row.add(TR("*** Nessuna ***")); // Should never happen! sheet.add(row); } else @@ -1291,7 +1291,7 @@ bool TCreadischi_mask::testpatch_handler(TMask_field& f, KEY k) TFilename path = app().mask().get(F_DISKPATH); path.add(module); path << "????a.ini"; - TArray_sheet sheet(3, 3, -3, -3, "File eliminabili", "@1|Percorso assoluto@70"); + TArray_sheet sheet(3, 3, -3, -3, TR("File eliminabili"), HR("@1|Percorso assoluto@70")); sheet.add_button(DLG_USER+1, "Dettagli", 'D'); sheet.set_handler(DLG_USER+1, why_handler); @@ -1301,7 +1301,7 @@ bool TCreadischi_mask::testpatch_handler(TMask_field& f, KEY k) if (inifiles.items() > 0) { - TProgind pi(inifiles.items(), "Scansione archivi...", FALSE, TRUE); + TProgind pi(inifiles.items(), TR("Scansione archivi..."), FALSE, TRUE); TAssoc_array files; TString_array para; TToken_string tok; @@ -1339,12 +1339,12 @@ bool TCreadischi_mask::testpatch_handler(TMask_field& f, KEY k) } if (inifiles.items() == 0) - return message_box("Non e' stato rilevato nessun file eliminabile"); + return message_box(TR("Non e' stato rilevato nessun file eliminabile")); if (sheet.run() == K_ENTER) { const long tot = sheet.checked(); - if (tot > 0 && yesno_box("Confermare la cancellazione di %ld file", tot)) + if (tot > 0 && yesno_box(FR("Confermare la cancellazione di %ld file"), tot)) { TWait_cursor hourglass; for (long i = sheet.items()-1; i >= 0; i--) if (sheet.checked(i)) @@ -1356,7 +1356,7 @@ bool TCreadischi_mask::testpatch_handler(TMask_field& f, KEY k) if (::remove(name) != 0) { if (d == 1) - error_box("Errore di cancellazione del file %s", (const char*)name); + error_box(FR("Errore di cancellazione del file %s"), (const char*)name); break; } } @@ -1391,9 +1391,9 @@ bool TCreadischi_mask::import_export_handler(TMask_field& f, KEY k) DIRECTORY dir; xvt_fsys_get_dir(&dir); // Salva directory corrente (Non usare la bacata xvt_fsys_save_dir) if (is_export) - ok = xvt_dm_post_file_save(&fs, "Esporta il modulo in:") == FL_OK; + ok = xvt_dm_post_file_save(&fs, TR("Esporta il modulo in:")) == FL_OK; else - ok = xvt_dm_post_file_open(&fs, "Importa il modulo da:") == FL_OK; + ok = xvt_dm_post_file_open(&fs, TR("Importa il modulo da:")) == FL_OK; xvt_fsys_set_dir(&dir); // Ripristina directory corrente if (ok) @@ -1517,7 +1517,7 @@ void TFascicolator_mask::save() TSheet_field& s = sfield(F_SHEET); TCreadischi_mask::save(); - TProgind pi(s.items(), "Salvataggio in corso...", FALSE, TRUE); + TProgind pi(s.items(), TR("Salvataggio in corso..."), FALSE, TRUE); TInstall_ini ini; TString tmp; @@ -1557,7 +1557,7 @@ void TFascicolator_mask::save() bool TCreadischi_mask::zip_file(const char* archive, const char* listfile) const { TString msg; - msg << "Creazione del file compresso " << archive << "..."; + msg << TR("Creazione del file compresso ") << archive << "..."; TIndwin waitw(100,msg,FALSE,FALSE); TWait_cursor hourglass; @@ -1579,10 +1579,10 @@ bool TCreadischi_mask::move_file(const TFilename& file, const char* dir) const if (!space_ok) { TString msg(128); - msg << "Lo spazio sull'unita' e' insufficiente"; + msg << TR("Lo spazio sull'unita' e' insufficiente"); if (::os_is_removable_drive(dest)) { - msg << ":\nInserire un nuovo disco e ritentare?"; + msg << TR(":\nInserire un nuovo disco e ritentare?"); if (!yesno_box(msg)) return FALSE; } @@ -1600,7 +1600,7 @@ bool TCreadischi_mask::move_file(const TFilename& file, const char* dir) const ::remove(file); else { - if (!yesno_box("Errore di copia del file %s.\nSi desidera riprovare?", + if (!yesno_box(FR("Errore di copia del file %s.\nSi desidera riprovare?"), (const char*)file)) user_abort = TRUE; } @@ -1627,7 +1627,7 @@ int TCreadischi_mask::split_file(const TFilename& archive, size_t chunk_size) co if (inf == NULL) return 0; - TString msg; msg << "Separazione del file " << archive << "..."; + TString msg; msg << TR("Separazione del file ") << archive << "..."; TProgind pi(tot_size, msg, FALSE, TRUE); byte* buff = new byte[chunk_size]; @@ -1742,7 +1742,7 @@ bool TCreadischi_mask::zip_module(const TString& main_module, bool agg, int patc if (agg) { if (patch_level <= 0) - return error_box("Il numero di patch deve essere superiore a zero"); + return error_box(TR("Il numero di patch deve essere superiore a zero")); TString16 name; name.format("%04da.ini", patch_level); sommario << name; // Nome del file sommario aggiornamento @@ -1754,7 +1754,7 @@ bool TCreadischi_mask::zip_module(const TString& main_module, bool agg, int patc if (arr.items() == 0) { ::remove(sommario); - return error_box("Nessun file da compattare"); + return error_box(TR("Nessun file da compattare")); } const TFilename path = get(F_DISKPATH); @@ -1768,9 +1768,9 @@ bool TCreadischi_mask::zip_module(const TString& main_module, bool agg, int patc // compilazione lista e relativa firma dei files TString msg; if (path.blank()) - msg << "Controllo dei file per " << archivio << " ..."; + msg << TR("Controllo dei file per ") << archivio << " ..."; else - msg << "Preparazione dei file per " << archivio << " ..."; + msg << TR("Preparazione dei file per ") << archivio << " ..."; TFilename filelist; filelist.temp("", main_module); @@ -1809,7 +1809,7 @@ bool TCreadischi_mask::zip_module(const TString& main_module, bool agg, int patc { // Se non trovo anche uno solo dei files nella lista, è un casino TString msg(128); - msg << "Impossibile aprire il file " << cmd << ". Interrompere?"; + msg << TR("Impossibile aprire il file ") << cmd << TR(". Interrompere?"); if (yesno_box(msg)) { aborted = TRUE; @@ -1823,7 +1823,7 @@ bool TCreadischi_mask::zip_module(const TString& main_module, bool agg, int patc // Se non specifico un path ho gia' finito if (path.blank()) { - message_box("Nessun percorso specificato. Il pacchetto non verra' creato"); + message_box(TR("Nessun percorso specificato. Il pacchetto non verra' creato")); return FALSE; } TFilename zipfile = path; @@ -1836,7 +1836,7 @@ bool TCreadischi_mask::zip_module(const TString& main_module, bool agg, int patc _stat((const char *)zipfile,&info); if (lasttime <= info.st_mtime) { - aborted = !yesno_box("Il file %s risulta già aggiornato.\nSi desidera rigenerarlo comunque?",(const char *)zipfile); + aborted = !yesno_box(FR("Il file %s risulta già aggiornato.\nSi desidera rigenerarlo comunque?"),(const char *)zipfile); } if (!aborted && !agg) { @@ -1849,7 +1849,7 @@ bool TCreadischi_mask::zip_module(const TString& main_module, bool agg, int patc { _stat((const char *)patchfile,&info); if (lasttime <= info.st_mtime) - aborted = !yesno_box("Il file di patch %s \nrisulta già aggiornato.\nSi desidera procedere comunque alla generazione di %s ?",(const char *)patchfile,(const char *)zipfile); + aborted = !yesno_box(FR("Il file di patch %s \nrisulta già aggiornato.\nSi desidera procedere comunque alla generazione di %s ?"),(const char *)patchfile,(const char *)zipfile); } } } @@ -1873,12 +1873,12 @@ bool TCreadischi_mask::zip_module(const TString& main_module, bool agg, int patc const char drive = toupper(path[0]); const bool floppy = os_is_removable_drive(path); - msg = "Creazione file "; msg << archivio; + msg = TR("Creazione file "); msg << archivio; TProgind pi(disks, msg, FALSE, TRUE); for (int d = 1; d <= disks && !aborted; d++) { if (floppy) - message_box("Inserire il disco %d di %d nell'unita':", d, disks); + message_box(TR("Inserire il disco %d di %d nell'unita':"), d, disks); // Costruisco il nome del file da copiare su dischetto TFilename src(archivio); @@ -1887,8 +1887,8 @@ bool TCreadischi_mask::zip_module(const TString& main_module, bool agg, int patc src.ext("zip"); msg.cut(0); - msg << "Generazione del disco " << d << " di " << disks - << " del modulo " << main_module << " ..."; + msg << TR("Generazione del disco ") << d << "/" << disks + << TR(" del modulo ") << main_module << " ..."; pi.set_text(msg); pi.addstatus(1); do_events(); @@ -2011,9 +2011,9 @@ int ba1600(int argc, char* argv[]) else { TCreazione_dischi app; - app.run(argc, argv, "Creazione dischetti"); + app.run(argc, argv, TR("Creazione dischetti")); } } else - error_box("L'utente %s non e' abilitato all'esecuzione di questo programma", (const char*)user()); + error_box(FR("L'utente %s non e' abilitato all'esecuzione di questo programma"), (const char*)user()); return 0; } diff --git a/ba/ba1700.cpp b/ba/ba1700.cpp index 7b5b7a4c7..390a827e7 100755 --- a/ba/ba1700.cpp +++ b/ba/ba1700.cpp @@ -79,7 +79,6 @@ bool is_internet_path(const TString& addr) class TInstaller_mask : public TArray_sheet { static TInstaller_mask* _curr_mask; - word _year_assist; bool _installed; // Flag per verificare se almeno un modulo e' stato installato enum {NONE, NEW_MENU, NEW_MENUPRG, NEW_INSTALLER} _reboot_program; protected: // TSheet @@ -276,7 +275,7 @@ bool TInstaller_mask::autoload() ininame = path; ininame.add(TInstall_ini::default_name()); - if (ininame.exist() && yesno_box("Si desidera svuotare la cache dei files scaricati dal sito?")) + if (ininame.exist() && yesno_box(TR("Si desidera svuotare la cache dei files scaricati dal sito?"))) { TString_array list; TFilename name = path; name.add("*.*"); @@ -291,12 +290,12 @@ bool TInstaller_mask::autoload() TFilename remote_ini = http_path; remote_ini << TInstall_ini::default_name(); { - TIndwin contacting(60,"Sto contattando il server HTTP...",FALSE,FALSE); + TIndwin contacting(60,TR("Sto contattando il server HTTP..."),FALSE,FALSE); httpresult=http_get(http_server, remote_ini, ininame); } - if (!httpresult) - return error_box("Impossibile trasferire %s da %s", - (const char*)remote_ini, (const char*)http_server); +// if (!httpresult) +// return error_box(FR("Impossibile trasferire %s da %s"), +// (const char*)remote_ini, (const char*)http_server); } } @@ -306,7 +305,7 @@ bool TInstaller_mask::autoload() ininame.add(TInstall_ini::default_name()); } else - return error_box("Specificare un percorso valido"); + return error_box(TR("Specificare un percorso valido")); TWait_cursor hourglass; destroy(); @@ -384,7 +383,7 @@ bool TInstaller_mask::autoload() if (!ininame.exist() && !http_get(http_server, remote, ininame)) { - error_box("Errore di trasferimento del file %s", (const char*)remote); + error_box(FR("Errore di trasferimento del file %s"), (const char*)remote); modules.destroy(i); } str = ininame; @@ -408,7 +407,7 @@ bool TInstaller_mask::autoload() TString& ininame = *arow; ininame.lower(); const int pos = ininame.find("a.ini"); - CHECKS(pos >= 6, "Invalid installation configuration: ", (const char*)ininame); + CHECKS(pos >= 6, TR("Invalid installation configuration: "), (const char*)ininame); const TString16 module = ininame.mid(pos-6, 2); TConfig ini(ininame, module); ini.write_protect(); @@ -436,8 +435,7 @@ bool TInstaller_mask::autoload() const bool ok = precheck_modules() > 0; if (!ok) - error_box("Non e' stato trovato nessun modulo da installare\n" - "in %s", (const char*)path); + error_box(FR("Non e' stato trovato nessun modulo da installare\nin %s"), (const char*)path); return ok; } @@ -478,22 +476,22 @@ bool TInstaller_mask::can_install(const char* module, TInstall_ini& ini) if (curini.demo() != ini.demo()) { TString msg; - msg << "Attenzione: Non e' possibile installare la versione "; - msg << (ini.demo() ? "dimostrativa" : "normale"); - msg << " nella cartella della versione "; - msg << (curini.demo() ? "dimostrativa" : "normale"); + msg << TR("Attenzione: Non e' possibile installare la versione "); + msg << (ini.demo() ? TR("dimostrativa") : TR("normale")); + msg << TR(" nella cartella della versione "); + msg << (curini.demo() ? TR("dimostrativa") : TR("normale")); return error_box(msg); } const TString& version = ini.version(module); const word year = version2year(version); if (year < 1997) - return error_box("Il modulo '%s' non ha una versione valida.", module); + return error_box(FR("Il modulo '%s' non ha una versione valida."), module); #ifndef _DEMO_ - if (year > _year_assist) - return error_box("Per installare la versione %s del modulo '%s'\n" - "occorre il contratto di assistenza per l'anno %d.", + if (year > dongle().year_assist()) + return error_box(FR("Per installare la versione %s del modulo '%s'\noccorre il contratto di assistenza per l'anno %d."), + (const char*)version, module, year); #endif @@ -511,9 +509,9 @@ bool TInstaller_mask::can_install(const char* module, TInstall_ini& ini) if (curini.get("Versione", submodule).empty()) { TString msg; - msg << "L'installazione del modulo '" << module - << "'\nrichiede la presenza del modulo '" << submodule - << "':\nSi desidera procedere alla sua installazione?"; + msg << TR("L'installazione del modulo '") << module + << TR("'\nrichiede la presenza del modulo '") << submodule + << TR("':\nSi desidera procedere alla sua installazione?"); ok = yesno_box(msg); if (ok) ok = install(submodule, 0); @@ -563,10 +561,10 @@ bool TInstaller_mask::move_file(const TFilename& from, const TFilename& file, co if (!space_ok) { TString msg; - msg << "Lo spazio sull'unita' e' insufficiente"; + msg << TR("Lo spazio sull'unita' e' insufficiente"); if (os_is_removable_drive(dest)) { - msg << ":\nInserire un nuovo disco e ritentare?"; + msg << TR(":\nInserire un nuovo disco e ritentare?"); if (!yesno_box(msg)) return FALSE; } @@ -583,7 +581,7 @@ bool TInstaller_mask::move_file(const TFilename& from, const TFilename& file, co if (write_ok) ::remove(file); else - user_retry = yesno_box("Errore di copia del file %s.\nSi desidera ritentare?", + user_retry = yesno_box(FR("Errore di copia del file %s.\nSi desidera ritentare?"), (const char*)file); } while (!write_ok && user_retry); @@ -622,15 +620,15 @@ bool TInstaller_mask::move_module(const TString& module, TInstall_ini& ini, bool KEY TInstaller_mask::askdisk(TString & path, TFilename & cmdline, int d, int dischi, const char * modulo) { - TMask retry_mask("Inserimento dischi",1,80,10); + TMask retry_mask(TR("Inserimento dischi"),1,80,10); retry_mask.add_static((F_PATH==101 ? 102:101),0, - format("Inserire il disco %d di %d del modulo'%s' nell' unità indicata", d, dischi, modulo) + format(FR("Inserire il disco %d di %d del modulo'%s' nell' unità indicata"), d, dischi, modulo) ,2,2); - retry_mask.add_static(F_PATH+3,0,"oppure indicare un percorso diverso",2,3); + retry_mask.add_static(F_PATH+3,0,TR("oppure indicare un percorso diverso"),2,3); retry_mask.add_string(F_PATH,0,"",2,5,48); - retry_mask.add_button(DLG_OK,0,"Riprova",-12,7,9,2); + retry_mask.add_button(DLG_OK,0,TR("Riprova"),-12,7,9,2); retry_mask.add_button(DLG_QUIT,0,"",-22,7,9,2); retry_mask.set(F_PATH,path); KEY k; @@ -647,7 +645,7 @@ KEY TInstaller_mask::askdisk(TString & path, TFilename & cmdline, int d, int dis break; } else - error_box("Il percorso indicato non e' valido"); + error_box(TR("Il percorso indicato non e' valido")); } } while (TRUE); return k; @@ -705,9 +703,7 @@ bool TInstaller_mask::install(const TString& module, int patchlevel) const int dischi = ini->get_int("Dischi", module); ok = dischi > 0; if (!ok) - { - return error_box("Impossibile determinare il numero dei dischetti in %s",ininame.name()); - } + return error_box(FR("Impossibile determinare il numero dei dischetti in %s"),ininame.name()); else { if (patchlevel==0) @@ -720,10 +716,10 @@ bool TInstaller_mask::install(const TString& module, int patchlevel) } // *************** // decompressione - msg="Decompressione"; + msg = TR("Decompressione"); if (is_a_patch) - msg << " della patch " << patchlevel ; - msg << " del modulo '" << module << "' in corso..."; + msg << TR(" della patch ") << patchlevel ; + msg << TR(" del modulo '") << module << TR("' in corso..."); TProgind pi(dischi, msg, FALSE, TRUE); TFilename tempdir; tempdir.tempdir(); @@ -749,7 +745,7 @@ bool TInstaller_mask::install(const TString& module, int patchlevel) TFilename remote = chunk.name(); remote.insert(http_path, 0); if (!http_get(http_server, remote, chunk)) - error_box("Errore di trasferimento del file '%s'", (const char*)remote); + error_box(FR("Errore di trasferimento del file '%s'"), (const char*)remote); } ok = chunk.exist(); @@ -761,7 +757,7 @@ bool TInstaller_mask::install(const TString& module, int patchlevel) break; ok = chunk.exist(); if (!ok) - message_box("Impossibile trovare il file '%s'",(const char*)chunk); + message_box(FR("Impossibile trovare il file '%s'"),(const char*)chunk); } } @@ -770,8 +766,7 @@ bool TInstaller_mask::install(const TString& module, int patchlevel) const long required = fsize(chunk) * (dischi-d+1) * 4; if (!os_test_disk_free_space(tempdir, required)) { - ok = yesno_box("Lo spazio su disco potrebbe essere insufficiente:\n" - "Si desidera continuare ugualmente?"); + ok = yesno_box(TR("Lo spazio su disco potrebbe essere insufficiente:\nSi desidera continuare ugualmente?")); } } @@ -800,7 +795,7 @@ bool TInstaller_mask::install(const TString& module, int patchlevel) break; ok = fexist(cmdline); if (!ok) - message_box("Impossibile trovare %s\n",(const char*)cmdline); + message_box(FR("Impossibile trovare %s\n"),(const char*)cmdline); else { delete ini; @@ -811,7 +806,7 @@ bool TInstaller_mask::install(const TString& module, int patchlevel) if (ok) { msg.cut(0); - msg << "Aggiornamento del modulo '" << module << "' in corso..."; + msg << TR("Aggiornamento del modulo '") << module << TR("' in corso..."); pi.set_text(msg); ok = move_module(module, *ini, TRUE); @@ -874,7 +869,8 @@ bool TInstaller_mask::install(const TString& module, int patchlevel) if (ok) { msg.cut(0); - msg << "Copia del modulo '" << module << "' in corso ..."; + msg << TR("Copia del modulo '"); + msg << module << TR("' in corso ..."); TProgind pi(files, msg, TRUE, TRUE); TFilename src, dst; for (int f = 0; f < files && ok; f++) @@ -1013,7 +1009,7 @@ bool TInstaller_mask::path_handler(TMask_field& fld, KEY key) if (path.exist() || ::is_internet_path(path)) _curr_mask->autoload(); else - ok = fld.error_box("Specificare un percorso valido"); + ok = fld.error_box(TR("Specificare un percorso valido")); } } return ok; @@ -1041,7 +1037,7 @@ void TInstaller_mask::install_selection() if (version2year(newver) < 1998) { - error_box("Il modulo '%s' non ha una versione valida.", (const char*)modulo); + error_box(FR("Il modulo '%s' non ha una versione valida."), (const char*)modulo); continue; } @@ -1050,13 +1046,11 @@ void TInstaller_mask::install_selection() bool has_patch = row->get_char(C_ISPATCH) == '+'; const int cmp = compare_version(oldver, oldpatch, newver, newpatch); if (cmp == 0) - ok = noyes_box("Si desidera reinstallare la versione %s.%d del modulo '%s' ?", (const char*)newver, newpatch, (const char*)modulo); + ok = noyes_box(FR("Si desidera reinstallare la versione %s.%d del modulo '%s' ?"), (const char*)newver, newpatch, (const char*)modulo); if (!is_patch && cmp > 0) { TString256 msg; - msg.format("Si desidera ritornare alla versione %s.%d del modulo '%s' ?\n" - "Attenzione: non e' garantito il corretto\n" - "funzionamento di tutti i programmi!", (const char*)newver, newpatch, (const char*)modulo); + msg.format(FR("Si desidera ritornare alla versione %s.%d del modulo '%s' ?\nAttenzione: non e' garantito il corretto\nfunzionamento di tutti i programmi!"), (const char*)newver, newpatch, (const char*)modulo); ok = noyes_box(msg); } if (ok && is_patch) @@ -1065,7 +1059,7 @@ void TInstaller_mask::install_selection() if (!oldver.blank() ) { if (oldver != newver) - ok =error_box("Il modulo '%s' installato ha versione %s:\nimpossibile installare le patch della versione %s",(const char *)modulo,(const char *)oldver,(const char *)newver); + ok = error_box(FR("Il modulo '%s' installato ha versione %s:\nimpossibile installare le patch della versione %s"),(const char *)modulo,(const char *)oldver,(const char *)newver); } else ok =FALSE;//error_box("Impossibile installare le patch perche' il modulo '%s' non e' installato",(const char *)modulo); } @@ -1074,8 +1068,7 @@ void TInstaller_mask::install_selection() if (has_patch) { if (newver == oldver && newpatch >= oldpatch && - !noyes_box("Si desidera reinstallare l'intero modulo '%s'?\n" - "Rispondendo NO verranno installate le sole patch",(const char *)modulo)) + !noyes_box(FR("Si desidera reinstallare l'intero modulo '%s'?\nRispondendo NO verranno installate le sole patch"),(const char *)modulo)) { is_patch = TRUE; } @@ -1085,7 +1078,7 @@ void TInstaller_mask::install_selection() { ok = install_patches(modulo, oldver, oldpatch, FALSE) ; // installa l'ultima patch if (!ok) - message_box("Impossibile installare le patch del modulo '%s'",(const char *)modulo); + message_box(TR("Impossibile installare le patch del modulo '%s'"),(const char *)modulo); } else ok = install(modulo, 0); // installa il modulo @@ -1098,7 +1091,7 @@ void TInstaller_mask::install_selection() check(r,FALSE); // uncheck } if (installed()) - message_box("Installazione conclusa"); + message_box(TR("Installazione conclusa")); } bool TInstaller_mask::install_handler(TMask_field& fld, KEY key) @@ -1114,7 +1107,7 @@ bool TInstaller_mask::install_handler(TMask_field& fld, KEY key) if (some) _curr_mask->install_selection(); else - error_box("Selezionare uno o piu' moduli da installare."); + error_box(TR("Selezionare uno o piu' moduli da installare.")); } return TRUE; } @@ -1130,7 +1123,7 @@ bool TInstaller_mask::quit_handler(TMask_field& f, KEY k) const bool some = _curr_mask->one_checked(); _curr_mask->enable_check(check_on); if (some) - return noyes_box("Alcuni moduli sono selezionati per l'installazione.\nConfermare l'uscita"); + return noyes_box(TR("Alcuni moduli sono selezionati per l'installazione.\nConfermare l'uscita")); } return TRUE; } @@ -1165,19 +1158,19 @@ bool TInstaller_mask::on_key(KEY key) } TInstaller_mask::TInstaller_mask() - : TArray_sheet(0, 0, 0, 0, "Installazione", - "@1|Modulo@30|Cod.|Versione da\ninstallare@11|Livello\nPatch@8|Data\nRilascio@10|Versione\nInstallata@10|Livello\nPatch@8|Data\nInstallazione@13|Aggiornamento", + : TArray_sheet(0, 0, 0, 0, TR("Installazione"), + HR("@1|Modulo@30|Cod.|Versione da\ninstallare@11|Livello\nPatch@8|Data\nRilascio@10|Versione\nInstallata@10|Livello\nPatch@8|Data\nInstallazione@13|Aggiornamento"), 0x18, 3) { _curr_mask = this; _installed = FALSE; _reboot_program= NONE; - add_string(F_PATH, 0, "Installa da ", 1, 1, 50); - add_string(F_CURPATH, 0, "Installa in ", 1, 2, 50, "D"); + add_string(F_PATH, 0, PR("Installa da "), 1, 1, 50); + add_string(F_CURPATH, 0, PR("Installa in "), 1, 2, 50, "D"); - add_button(F_UPDATE, "Rileggi", '\0'); - add_button(F_INSTALL, "Installa", '\0'); // NON mettere 'I' + add_button(F_UPDATE, BR("Rileggi", 9), '\0'); + add_button(F_INSTALL, BR("Installa", 9), '\0'); // NON mettere 'I' set_handler(F_PATH, path_handler); set_handler(F_INSTALL, install_handler); @@ -1185,9 +1178,6 @@ TInstaller_mask::TInstaller_mask() set_handler(DLG_QUIT, quit_handler); set_handler(DLG_USER, tutti_handler); - TDongle dongle; dongle.login(); dongle.logout(); - _year_assist = dongle.year_assist(); - TInstall_ini ini; TFilename path = ini.get("DiskPath"); set(F_PATH, path); @@ -1212,29 +1202,29 @@ TInstaller_mask::~TInstaller_mask() switch (_reboot_program) { case NEW_MENU: - msg << "sono stati aggiornati i menu"; + msg << TR("sono stati aggiornati i menu"); default: if (ba0exfile.exist()) { if (!msg.blank()) - msg << " e "; + msg << TR(" e "); else - msg << "e' stato "; - msg << "aggiornato il navigatore dei menu"; + msg << TR("e' stato "); + msg << TR("aggiornato il navigatore dei menu"); } if (ba1exfile.exist()) { if (!msg.blank()) - msg << " e "; + msg << TR(" e "); else - msg << "e' stato "; - msg << "aggiornato l'installatore"; + msg << TR("e' stato "); + msg << TR("aggiornato l'installatore"); } } if (!msg.empty()) { - msg.insert("Attenzione:"); - msg << ".\nE' necessario uscire e rientrare dal programma"; + msg.insert(TR("Attenzione:")); + msg << TR(".\nE' necessario uscire e rientrare dal programma"); warning_box(msg); } } @@ -1298,7 +1288,7 @@ bool TInstaller::create() return TSkeleton_application::create(); } - return error_box("L'utente %s non è abilitato all'uso di questo programma", (const char *)user()); + return error_box(FR("L'utente %s non è abilitato all'uso di questo programma"), (const char *)user()); } void TInstaller::main_loop() @@ -1361,4 +1351,4 @@ int ba1700(int argc, char* argv[]) app.run(argc, argv, PROGNAME); } return 0; -} +} \ No newline at end of file diff --git a/ba/ba1800.cpp b/ba/ba1800.cpp index 98d0afa63..96f664415 100755 --- a/ba/ba1800.cpp +++ b/ba/ba1800.cpp @@ -56,7 +56,7 @@ HIDDEN int str2isamfile(const TString& str) HIDDEN int choose_isamfile(int selected) { - TArray_sheet sht(-1,-1,-4,-4,"Selezione archivio", "Codice|Descrizione archivio@70"); + TArray_sheet sht(-1,-1,-4,-4,TR("Selezione archivio"), HR("Codice|Descrizione archivio@70")); TToken_string tt(80); long sel = 0; @@ -358,13 +358,12 @@ public: class TFields_mask : public TAutomask { -protected: // TAutomask - virtual bool on_field_event(TOperable_field& of, TField_event fe, long jolly); protected: // Internal use bool field_handler(TOperable_field& of, TField_event fe); public: + virtual bool on_field_event(TOperable_field& of, TField_event fe, long jolly); TRelation_description* rel_desc() const; TFields_mask(const char* name, int number); @@ -409,7 +408,7 @@ bool TFields_mask::field_handler(TOperable_field& of, TField_event fe) } } else - ok = error_box("Selezionare un file valido"); + ok = error_box(TR("Selezionare un file valido")); } if (fe == fe_modify || fe_close) @@ -424,7 +423,7 @@ bool TFields_mask::field_handler(TOperable_field& of, TField_event fe) if (d && *d) set(F_DESCR, d); else - ok = error_box("Il campo %s non esiste", + ok = error_box(FR("Il campo %s non esiste"), (const char*)n, rd->file_desc()); } } @@ -451,11 +450,10 @@ class TFields_sheet : public TSheet_field protected: // TSheet_field virtual void create(WINDOW win); - virtual TMask& sheet_mask() const; public: void describe_fields(); - bool handler(TField_event fe, long row); + virtual TMask& sheet_mask() const; TFields_sheet(TAutomask* m); virtual ~TFields_sheet(); @@ -495,12 +493,6 @@ void TFields_sheet::describe_fields() } } -bool TFields_sheet::handler(TField_event fe, long row) -{ - bool ok = TRUE; - return ok; -} - TFields_sheet::TFields_sheet(TAutomask* m) : TSheet_field(m), _sheet_mask(NULL) { @@ -523,7 +515,7 @@ bool TWizard_mask::file_open(TFilename& fname) const strcpy(fs.name, fname); strcpy(fs.creator, "WIZ"); - const bool good = xvt_dm_post_file_open(&fs, "Selezionare il file ...") == FL_OK; + const bool good = xvt_dm_post_file_open(&fs, TR("Selezionare il file ...")) == FL_OK; xvt_fsys_set_dir(&dir); if (good) @@ -614,7 +606,7 @@ void TWizard_mask::save_ini(const TFilename& ininame) const if (!ininame.blank()) { if (!ininame.exist() || - yesno_box("Si desidera sovrascrivere il file %s", (const char*)ininame)) + yesno_box(FR("Si desidera sovrascrivere il file %s"), (const char*)ininame)) { TConfig ini(ininame, "MAIN"); ini.remove_all(); @@ -947,7 +939,7 @@ bool TWizard_mask::file_handler(TOperable_field& f, TField_event e) file_preview(); } else - ok = error_box("Il file non esiste"); + ok = error_box(TR("Il file non esiste")); } return ok; } @@ -1013,7 +1005,7 @@ bool TWizard_mask::isamfile_handler(TOperable_field& f, TField_event e) fs.describe_fields(); } else - ok = error_box("File dati non valido"); + ok = error_box(TR("File dati non valido")); can_import &= fexist(get(F_FILE)); enable(F_IMPORT, can_import); reset(F_ZAP); @@ -1029,23 +1021,23 @@ bool TWizard_mask::import_file() const TFilename filename = get(F_FILE); if (!filename.exist()) - return error_box("Il file %s non esiste", (const char*)filename); + return error_box(FR("Il file %s non esiste"), (const char*)filename); const int logicnum = str2isamfile(get(F_ISAM)); if (logicnum <= 0) - return error_box("E' necessario specificare un file di destinazione valido"); + return error_box(TR("E' necessario specificare un file di destinazione valido")); rel_desc(0); // Chiude il file isam correntemente in uso, altrimenti niente _excllock TSystemisamfile sif(logicnum); int err = sif.open_ex(_excllock); if (err != NOERR) - return error_box("Impossibile aprire il file %d: errore %d", logicnum, err); + return error_box(FR("Impossibile aprire il file %d: errore %d"), logicnum, err); const bool empty = sif.items() == 0L; sif.close(); if (get_bool(F_ZAP)) { - if (!empty && yesno_box("Procedere con l'azzeramento del file %d?", logicnum)) + if (!empty && yesno_box(FR("Procedere con l'azzeramento del file %d?"), logicnum)) sif.packfile(FALSE, TRUE); } @@ -1062,14 +1054,14 @@ bool TWizard_mask::import_file() err = txt.autosave(rec); if (err != NOERR) { - ok = error_box("Errore %d durante la scrittura del record %ld:", + ok = error_box(FR("Errore %d durante la scrittura del record %ld:"), err, numrec); break; } } } else - ok = error_box("Impossibile leggere il file %s", (const char*)filename); + ok = error_box(FR("Impossibile leggere il file %s"), (const char*)filename); } else { @@ -1079,11 +1071,11 @@ bool TWizard_mask::import_file() if (err == NOERR) ok = sif.load(filename) == NOERR; else - ok = error_box("Impossibile aprire il file %d: errore %d", logicnum, err); + ok = error_box(FR("Impossibile aprire il file %d: errore %d"), logicnum, err); sif.close(); } else - ok = error_box("Il file %s non esiste", (const char*)ininame); + ok = error_box(FR("Il file %s non esiste"), (const char*)ininame); } return ok; } @@ -1091,44 +1083,51 @@ bool TWizard_mask::import_file() bool TWizard_mask::on_field_event(TOperable_field& f, TField_event e, long jolly) { bool ok = TRUE; - switch(f.dlg()) - { - case F_FILE: - ok = file_handler(f, e); - break; - case F_INI: - ok = ini_handler(f, e); - break; - case F_RECLEN: - case F_RECSEP: - case F_FIELDSEP: - case F_SKIPLINES: - case F_DISPLINES: - case F_FIXEDLEN: - if (e == fe_modify) - file_preview(); - break; - case F_ISAM: - ok = isamfile_handler(f, e); - break; - case F_SAVE: - if (e == fe_button) - save_ini(get(F_INI)); - break; - case F_IMPORT: - 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; - default: - break; - } + + if (jolly == 0) + { + switch(f.dlg()) + { + case F_FILE: + ok = file_handler(f, e); + break; + case F_INI: + ok = ini_handler(f, e); + break; + case F_RECLEN: + case F_RECSEP: + case F_FIELDSEP: + case F_SKIPLINES: + case F_DISPLINES: + case F_FIXEDLEN: + if (e == fe_modify) + file_preview(); + break; + case F_ISAM: + ok = isamfile_handler(f, e); + break; + case F_SAVE: + if (e == fe_button) + save_ini(get(F_INI)); + break; + case F_IMPORT: + if (e == fe_button) + import_file(); + break; + case F_COLUMNIZER: + if (e == fe_init) + file_preview(); // Indispensabile! + break; + default: + break; + } + } + else + { + TFields_sheet& fs = (TFields_sheet&)sfield(F_FIELDS); + + ok = ((TFields_mask&)fs.sheet_mask()).on_field_event(f, e, 0); + } return ok; } @@ -1176,6 +1175,6 @@ void TImport_wizard::main_loop() int ba1800(int argc, char* argv[]) { TImport_wizard of_oz; - of_oz.run(argc, argv, "Import Wizard"); + of_oz.run(argc, argv, TR("Import Wizard")); return 0; } diff --git a/ba/ba1900.cpp b/ba/ba1900.cpp index 1f7d7164a..0e61a8586 100755 --- a/ba/ba1900.cpp +++ b/ba/ba1900.cpp @@ -5,12 +5,6 @@ #include "ba1900.h" -const char* Translate(const char* str) -{ return str; } - -#define TR(str) Translate("\03\02\01\00"##str) - - /////////////////////////////////////////////////////////// // Main mask /////////////////////////////////////////////////////////// diff --git a/ba/ba2100.cpp b/ba/ba2100.cpp index d6d2304b7..e0a0f4ec3 100755 --- a/ba/ba2100.cpp +++ b/ba/ba2100.cpp @@ -4,6 +4,6 @@ int ba2100(int argc, char* argv[]) { TForm_editor a; - a.run(argc, argv, "Parametrizzazione stampa"); + a.run(argc, argv, TR("Parametrizzazione stampa")); return 0; } diff --git a/ba/ba2200.cpp b/ba/ba2200.cpp index 761eb795d..0bd702465 100755 --- a/ba/ba2200.cpp +++ b/ba/ba2200.cpp @@ -79,14 +79,14 @@ bool TArchive_mask::on_field_event(TOperable_field& o, TField_event e, long joll case F_DITTA: if (e == fe_modify || e == fe_init) { - set(F_RAGSOC, (o.get() != "") ? "Tutte le ditte" : "Nessuna ditta"); + set(F_RAGSOC, (o.get() != "") ? TR("Tutte le ditte") : TR("Nessuna ditta")); } break; case F_CODDITTA: if (e == fe_modify) { if (o.empty()) - set(F_RAGSOC, o.active() ? "Tutte le ditte" : "Nessuna ditta"); + set(F_RAGSOC, o.active() ? TR("Tutte le ditte") : TR("Nessuna ditta")); } break; case F_SALVA: @@ -94,7 +94,7 @@ bool TArchive_mask::on_field_event(TOperable_field& o, TField_event e, long joll { const long ditta = get_long(F_CODDITTA); if (ditta > 0L && !prefix().exist(ditta)) - return error_box("La ditta %ld non esiste", ditta); + return error_box(FR("La ditta %ld non esiste"), ditta); } default: break; @@ -116,10 +116,7 @@ bool TArchive_app::create() { const TString16 u = utenti.get("USERNAME"); if (u != user() && utenti.get_bool("CONNECTED")) - { - ok = error_box("L'archiviazione non puo' essere effettuata\n" - "se ci sono altri utenti collegati (%s)", (const char*)u); - } + ok = error_box(FR("L'archiviazione non puo' essere effettuata\nse ci sono altri utenti collegati (%s)"), (const char*)u); } utenti.close(); @@ -224,7 +221,7 @@ bool TArchive_app::zip_dir(const TFilename& name, unsigned long max_chunk) TFilename filenames = name; filenames.add("*.*"); TString msg; - msg << "Creazione del file temporaneo " << tmp << "..."; + msg << TR("Creazione del file temporaneo ") << tmp << "..."; TIndwin waitw(100,msg,FALSE,FALSE); TWait_cursor hourglass; @@ -267,11 +264,11 @@ void TArchive_app::save_zip_files(const TFilename& floppy_path, const TString& d bool ok = TRUE; if (os_is_removable_drive(floppy_path.left(3))) { - const char* msg = "Si desidera procedere con l'operazione di salvataggio?"; + const char* msg = TR("Si desidera procedere con l'operazione di salvataggio?"); if (disk == 1) - ok = yesno_box("Controllare che il primo disco sia nel drive %c:\n%s", floppy_path[0], msg); + ok = yesno_box(FR("Controllare che il primo disco sia nel drive %c:\n%s"), floppy_path[0], msg); else - ok = yesno_box("Preparare %d dischetti vuoti e controllare che il primo sia nel drive %c:\n%s", disk, floppy_path[0], msg); + ok = yesno_box(FR("Preparare %d dischetti vuoti e controllare che il primo sia nel drive %c:\n%s"), disk, floppy_path[0], msg); if (!ok) return; } @@ -304,19 +301,18 @@ void TArchive_app::save_zip_files(const TFilename& floppy_path, const TString& d int curr_disk = 1; - TProgind pi(_zip_list.items(), "Salvataggio dati in corso...", FALSE, TRUE); + TProgind pi(_zip_list.items(), TR("Salvataggio dati in corso..."), FALSE, TRUE); for (i = 0; i < _zip_list.items(); i++) { pi.addstatus(1); const TAFile_info& fi = (const TAFile_info&)_zip_list[i]; if (fi._disk != curr_disk) - message_box("Inserire il disco vuoto n.%d", curr_disk = fi._disk); + message_box(FR("Inserire il disco vuoto n.%d"), curr_disk = fi._disk); TFilename dest; dest = floppy_path; dest.add(fi._name.name()); while(!can_save_as(fi._name, dest)) { - if (!yesno_box("Sul disco %d non c'e' spazio sufficiente per il file %s" - "\nSi desidera sostituire il disco e ritentare?", curr_disk, (const char*)dest)) + if (!yesno_box(FR("Sul disco %d non c'e' spazio sufficiente per il file %s\nSi desidera sostituire il disco e ritentare?"), curr_disk, (const char*)dest)) return; } fcopy(fi._name, dest); @@ -345,7 +341,7 @@ void TArchive_app::backup(int mode, long firm, const TFilename& floppy_path, con long max_chunk = ~0; if (os_is_removable_drive(floppy_path)) { - message_box("Inserire un disco vuoto nel drive %c:", floppy_path[0]); + message_box(FR("Inserire un disco vuoto nel drive %c:"), floppy_path[0]); max_chunk = os_get_disk_size(floppy_path) - (1024L*64L); } @@ -392,7 +388,7 @@ void TArchive_app::backup(int mode, long firm, const TFilename& floppy_path, con if (ok) save_zip_files(floppy_path, desc, max_chunk); else - error_box("Si è verificato un errore di accesso al disco:\nVerificare lo spazio disponibile"); + error_box(TR("Si è verificato un errore di accesso al disco:\nVerificare lo spazio disponibile")); } bool TArchive_app::read_paragraph(TConfig& ini, const char* para) @@ -425,14 +421,14 @@ void TArchive_app::load_zip_files(const TFilename& floppy_path) TString msg; TFilename dir; dir.tempdir(); const int files = _zip_list.items(); - TProgind pi(files, "Ripristino dati in corso...", TRUE, TRUE); + TProgind pi(files, TR("Ripristino dati in corso..."), TRUE, TRUE); int curr_disk = 1; for (int i = 0; i < files; i++) { const TAFile_info& info = (const TAFile_info&)_zip_list[i]; const int& disk = info._disk; - msg = "Ripristino "; msg << info._name.name() << " in corso..."; + msg = TR("Ripristino "); msg << info._name.name() << TR(" in corso..."); pi.set_text(msg); pi.addstatus(1); if (pi.iscancelled()) @@ -442,7 +438,7 @@ void TArchive_app::load_zip_files(const TFilename& floppy_path) { if (disk != curr_disk) { - message_box("Inserire il disco %d del backup", disk); + message_box(FR("Inserire il disco %d del backup"), disk); curr_disk = disk; } } @@ -450,7 +446,7 @@ void TArchive_app::load_zip_files(const TFilename& floppy_path) TFilename src; src = floppy_path; src.add(info._name.name()); TFilename dst; dst = dir; dst.add(info._name.name()); dst.ext("zip"); while (!fcopy(src, dst, TRUE)) - if (!yesno_box("Si desidera ritentare?")) + if (!yesno_box(TR("Si desidera ritentare?"))) return; if (disk == info._last_disk) { @@ -502,7 +498,7 @@ void TArchive_app::restore(int mode, long firm, const TFilename& floppy_path) if (tot > 0) { TString fola; - fola = "Verranno ripristinati i seguenti archivi:\n"; + fola = TR("Verranno ripristinati i seguenti archivi:\n"); for (int i = 0; i < tot; i++) { const TAFile_info& info = (const TAFile_info&)_zip_list[i]; @@ -514,7 +510,7 @@ void TArchive_app::restore(int mode, long firm, const TFilename& floppy_path) } } fola.rtrim(2); - fola << ".\nSi desidera continuare?"; + fola << TR(".\nSi desidera continuare?"); if (yesno_box(fola)) { const TString16 old = prefix().name(); @@ -524,7 +520,7 @@ void TArchive_app::restore(int mode, long firm, const TFilename& floppy_path) } } else - warning_box("I dati richiesti non sono presenti sul backup"); + warning_box(TR("I dati richiesti non sono presenti sul backup")); } void TArchive_app::interactive_mode() @@ -547,15 +543,15 @@ void TArchive_app::interactive_mode() { TFilename ini_name = floppy_path; ini_name.add("backup.ini"); if (os_is_removable_drive(floppy_path.left(3))) - message_box("Inserire il primo disco del backup nel drive %c", floppy_path[0]); + message_box(FR("Inserire il primo disco del backup nel drive %c"), floppy_path[0]); if (ini_name.exist()) restore(mode, firm, floppy_path); else - error_box("Impossibile trovare il file %s", (const char*)ini_name); + error_box(FR("Impossibile trovare il file %s"), (const char*)ini_name); } } else - error_box("Non e' stato specificato nessun archivio"); + error_box(TR("Non e' stato specificato nessun archivio")); } } @@ -616,7 +612,7 @@ void TArchive_app::main_loop() int ba2200(int argc, char* argv[]) { TArchive_app a; - a.run(argc, argv, "Archiviazione"); + a.run(argc, argv, TR("Archiviazione")); return 0; } diff --git a/ba/ba2300.cpp b/ba/ba2300.cpp index db2b3f592..0984e529d 100755 --- a/ba/ba2300.cpp +++ b/ba/ba2300.cpp @@ -315,7 +315,7 @@ void TAutoform_app::main_loop() if (tf.goto_selected() && !tree.has_son()) { TString desc; tree.get_description(desc); - if (yesno_box("Si desidera caricare i dati\n%s?", (const char*)desc)) + if (yesno_box(FR("Si desidera caricare i dati\n%s?"), (const char*)desc)) { desc.cut(5); const short dlg = desc.right(1) == "I" ? F_STUDENT : F_SOLUTION; @@ -335,6 +335,6 @@ void TAutoform_app::main_loop() int ba2300(int argc, char* argv[]) { TAutoform_app app; - app.run(argc, argv, "Autoformazione"); + app.run(argc, argv, TR("Autoformazione")); return 0; } diff --git a/ba/ba2400.cpp b/ba/ba2400.cpp index 735358d8c..95aaa5168 100755 --- a/ba/ba2400.cpp +++ b/ba/ba2400.cpp @@ -26,7 +26,7 @@ TTab_form::TTab_form(const char* name, const char * code) : TForm(name, code) { TCursor* c = cursor(); if (c == NULL) - fatal_box("Il profilo %s non ha un cursore", name); + fatal_box(FR("Il profilo %s non ha un cursore"), name); TFilename t("tmp");t << LF_TABCOM; TIsamtempfile* tmp = new TIsamtempfile(LF_TABCOM, t, FALSE); relation()->replace(tmp); @@ -155,7 +155,7 @@ bool TForm_printer::create() if (argc() == 4) code = atol(argv(3)); if (!fexist(form)) - return error_box("Il profilo %s non esiste", (const char*)form); + return error_box(FR("Il profilo %s non esiste"), (const char*)form); form.ext(""); _tabcom = new TLocalisamfile(LF_TABCOM); cod_prof.format("%05ld",code); @@ -174,6 +174,7 @@ bool TForm_printer::destroy() int ba2400(int argc, char* argv[]) { TForm_printer a; - a.run(argc, argv, "Stampa versamenti"); + + a.run(argc, argv, TR("Stampa versamenti")); return 0; } diff --git a/ba/ba2500.cpp b/ba/ba2500.cpp index a51f58330..3c5589309 100755 --- a/ba/ba2500.cpp +++ b/ba/ba2500.cpp @@ -52,8 +52,8 @@ bool TStampa_deleghe_IVA::create() _banche = new TTable("%BAN"); - _ditte = new TArray_sheet(-1, -1, 0, 0, "Selezione Deleghe da stampare", - "@1|Cod.@5|Ragione Sociale@30|Importo@15r|Interessi@15r|ABI@5|CAB@5|Concessione|Tit. Conto Fis."); + _ditte = new TArray_sheet(-1, -1, 0, 0, TR("Selezione Deleghe da stampare"), + HR("@1|Cod.@5|Ragione Sociale@30|Importo@15r|Interessi@15r|ABI@5|CAB@5|Concessione|Tit. Conto Fis.")); _azienda = "" ; _dipendenza = "" ; @@ -164,7 +164,7 @@ int TStampa_deleghe_IVA::select() } else { - warning_box("Nessuna ditta ha deleghe del tipo specificato"); + warning_box(TR("Nessuna ditta ha deleghe del tipo specificato")); res = 2; } @@ -181,15 +181,13 @@ void TStampa_deleghe_IVA::main_loop() void TStampa_deleghe_IVA::print() { - bool ok = yesno_box("Inserire il modulo prefincato nella stampante " - "e confermare la stampa delle deleghe"); + bool ok = yesno_box(TR("Inserire il modulo prefincato nella stampante e confermare la stampa delle deleghe")); if (ok) { print_deleghe(); if (_stampa_distinte) { - ok = yesno_box("Inserire il modulo in carta bianca nella stampante " - "e confermare la stampa della distinta"); + ok = yesno_box(TR("Inserire il modulo in carta bianca nella stampante e confermare la stampa della distinta")); if (ok) print_distinta(); } } @@ -215,28 +213,28 @@ void TStampa_deleghe_IVA::print_distinta() if (atol(_azienda)) row.put(_banche->get("S0"), 0); - row.put("@bDISTINTA DELEGHE DI VERSAMENTO", TAB_SEDE); - row.put("Data @>", 106); - row.put("Pag.@#", 124); + row.put(FR("@bDISTINTA DELEGHE DI VERSAMENTO"), TAB_SEDE); + row.put(FR("Data @>"), 106); + row.put(FR("Pag.@#"), 124); printer().setheaderline(0, row); row.reset(); if (atol(_dipendenza)) row.put(_banche->get("S1"), 0); - TString256 t("Dichiarazione "); + TString256 t; switch (_tipo) { case 2: - t << "annuale :"; break; + t << TR("Dichiarazione annuale :"); break; case 3: - t << "articolo 74 : " << itom(_mese); break; + t << TR("Dichiarazione articolo 74 : ") << itom(_mese); break; case 4: - t << "cessazione attivita' : " << itom(_mese); break; + t << TR("Dichiarazione cessazione attivita' : ") << itom(_mese); break; case 5: - t << "integrativa : " << itom(_mese); break; + t << TR("Dichiarazione integrativa : ") << itom(_mese); break; default: - t << "periodica : " << itom(_mese); break; + t << TR("Dichiarazione periodica : ") << itom(_mese); break; } t << ' ' << _anno; row.put(t, TAB_SEDE); @@ -249,10 +247,10 @@ void TStampa_deleghe_IVA::print_distinta() printer().setheaderline(4, row); row.reset(); - row.put("Ditta", TAB_DITTA); - row.put("Sede" , TAB_SEDE); - row.put("Importo", TAB_IMPORTO+8); - row.put("Note", TAB_NOTE); + row.put(TR("Ditta"), TAB_DITTA); + row.put(TR("Sede") , TAB_SEDE); + row.put(TR("Importo"), TAB_IMPORTO+8); + row.put(TR("Note"), TAB_NOTE); printer().setheaderline(3, row); real totale; @@ -290,7 +288,7 @@ void TStampa_deleghe_IVA::print_distinta() row.reset(); printer().print(row); - row.put("@bTotale versamenti :", TAB_SEDE); + row.put(FR("@bTotale versamenti :"), TAB_SEDE); row.put(totale.string("###.###.###.###"), TAB_IMPORTO); printer().print(row); @@ -433,6 +431,6 @@ bool TStampa_deleghe_IVA::print_deleghe() int ba2500(int argc, char* argv[]) { TStampa_deleghe_IVA a; - a.run(argc, argv, "Stampa Deleghe IVA"); + a.run(argc, argv, TR("Stampa Deleghe IVA")); return 0; } diff --git a/ba/ba2600.cpp b/ba/ba2600.cpp index b8b0a551a..71df982dc 100755 --- a/ba/ba2600.cpp +++ b/ba/ba2600.cpp @@ -13,8 +13,8 @@ TEditMask_window::TEditMask_window(short x,short y,short dx,short dy, set_font(); _sheet=NULL; _total_page=_page=1; - _name.add("Maschera",0); - _name.add("Maschera",1); + _name.add(TR("Maschera"),0); + _name.add(TR("Maschera"),1); _type_vz="a"; _coordx=x; _coordy=y; _alt=dy; _lung=dx; @@ -586,7 +586,7 @@ TEditMask_string::TEditMask_string(TEditMask_window* parent): _lungvd=_lungsz=15; _lngspt=0; _offset = 1; - set_prompt("Stringa"); + set_prompt(PR("Stringa")); set_type("STRING "); set_id("F_STRING"); set_dim(_lungvd+prompt_len()+off(),1); @@ -808,7 +808,7 @@ TEditMask_number::TEditMask_number(TEditMask_window* parent) { _latox=10; _decimals=0; - set_prompt("Number"); + set_prompt(PR("Numero")); set_type("NUMBER "); set_id("F_NUMBER"); set_dim(_latox + prompt_len() + off(),1); @@ -915,7 +915,7 @@ TEditMask_currency::TEditMask_currency(TEditMask_window* parent) { _latox=10; set_picture(""); - set_prompt("Currency"); + set_prompt(PR("Valuta ")); set_type("CURRENCY "); set_id("F_CUR"); set_dim(_latox + prompt_len(),1); @@ -973,7 +973,7 @@ void TEditMask_currency::read_from(TScanner& scanner,bool intool) TEditMask_date::TEditMask_date(TEditMask_window* parent) :TEditMask_string(parent) { - set_prompt("Date"); + set_prompt(PR("Data")); set_type("DATE "); set_dim(10+prompt_len()+off(),1); set_id("F_DATE"); @@ -1050,7 +1050,7 @@ TEditMask_boolean::TEditMask_boolean(TEditMask_window* parent) { set_type("BOOLEAN "); set_id("F_CHECK"); - set_prompt("Check Box"); + set_prompt(PR("Booleano ")); set_dim(prompt_len()+2,1); } @@ -1139,7 +1139,7 @@ void TEditMask_boolean::read_from(TScanner& scanner,bool intool) TEditMask_text::TEditMask_text(TEditMask_window* parent) :TEditMask_string(parent) { - set_prompt("Text"); + set_prompt(PR("Testo")); set_dim(prompt_len(),1); set_type("TEXT "); set_id("DLG_NULL"); @@ -1223,7 +1223,7 @@ TEditMask_button::TEditMask_button(TEditMask_window* parent) _latox=10; _latoy=2; - set_prompt("BUTTON"); + set_prompt(FR("Bottone")); set_type("BUTTON "); set_id("DLG_NULL"); set_dim(_latox+2,_latoy); @@ -1248,17 +1248,17 @@ void TEditMask_button::type_button(const TString& id,const TString& pr) if(pr=="") { // if(id=="DLG_NULL") ; - if(id=="DLG_OK") set_prompt("Conferma") ; + if(id=="DLG_OK") set_prompt(BR("Conferma", 9)) ; else - if(id=="DLG_CANCEL") set_prompt("Annulla"); + if(id=="DLG_CANCEL") set_prompt(BR("Annulla", 9)); else - if(id=="DLG_DELREC") set_prompt("Elimina"); + if(id=="DLG_DELREC") set_prompt(BR("Elimina", 9)); else - if(id=="DLG_QUIT") set_prompt("Fine"); + if(id=="DLG_QUIT") set_prompt(BR("Fine", 9)); else - if(id=="DLG_PRINT") set_prompt("Stampa"); + if(id=="DLG_PRINT") set_prompt(BR("Stampa", 9)); else - if(id=="DLG_SELECT") set_prompt("Seleziona"); + if(id=="DLG_SELECT") set_prompt(BR("Seleziona", 9)); } } @@ -1352,7 +1352,7 @@ void TEditMask_button::read_from(TScanner& scanner,bool intool) TEditMask_group::TEditMask_group(TEditMask_window* parent) :TEditMask_control(parent) { - set_prompt("GRUPPO n."); + set_prompt(PR("Gruppo")); set_type("GROUPBOX "); set_id("DLG_NULL"); _latox=18; @@ -1466,7 +1466,7 @@ TEditMask_list::TEditMask_list(TEditMask_window* parent) _num_item=0; _offset=1; set_id("F_LIST"); - set_prompt("Lista"); + set_prompt(PR("Lista")); set_type("LIST "); set_dim(dim_video()+ prompt_len()+off(),1); } @@ -1656,7 +1656,7 @@ TEditMask_radio::TEditMask_radio(TEditMask_window* parent) _latox=20; _latoy=4; set_id("F_RADIO"); - set_prompt("Radio Button"); + set_prompt(PR("Pulsantiera")); set_type("RADIOBUTTON "); set_dim(_latox,_latoy); } @@ -1788,7 +1788,7 @@ TEditMask_memo::TEditMask_memo(TEditMask_window* parent) { _latox=40; _latoy=10; - set_prompt("Memo"); + set_prompt(PR("Memo")); set_type("MEMO "); set_id("F_MEMO"); set_dim(_latox,_latoy); @@ -1882,7 +1882,7 @@ TEditMask_sheet::TEditMask_sheet(TEditMask_window* parent) _latox=40; _latoy=6; set_dim(_latox,_latoy); - set_prompt("Spreadsheet"); + set_prompt(PR("Tabella")); set_type("SPREADSHEET "); set_id("F_SPREAD"); _sheetmask.set_sheet(this); @@ -1912,20 +1912,20 @@ void TEditMask_sheet::window_sheet() DRAW_CTOOLS t; TEditMask_control* btn_ok=_sheetmask.addbutton(); - btn_ok->set_prompt("Conferma"); + btn_ok->set_prompt(BR("Conferma", 9)); btn_ok->set_id("DLG_OK"); btn_ok->set_crd(-13,-1); btn_ok->set_dim(10+2,2); TEditMask_control* btn_cancel=_sheetmask.addbutton(); - btn_cancel->set_prompt("Annulla"); + btn_cancel->set_prompt(BR("Annulla", 9)); btn_cancel->set_id("DLG_CANCEL"); btn_cancel->set_crd(-23,-1); btn_cancel->set_dim(10+2,2); TEditMask_control* btn_del=_sheetmask.addbutton(); - btn_del->set_prompt("Elimina"); + btn_del->set_prompt(BR("Elimina", 9)); btn_del->set_id("DLG_DELREC"); btn_del->set_crd(-33,-1); btn_del->set_dim(10+2,2); @@ -2134,7 +2134,7 @@ TEditMask_zoom::TEditMask_zoom(TEditMask_window* parent) _latox=15; _offset=1; set_id("F_ZOOM"); - set_prompt("Zoom"); + set_prompt(PR("Zoom")); set_type("ZOOM "); set_dim(_latox+prompt_len()+off(),1); } @@ -2397,15 +2397,14 @@ void TEditMask_window::move_crt_sel() if(k==K_ENTER) { if(xvt_rect_is_empty(&_rct_sel)) - warning_box("Pensi di avere selezionato qualcosa??"); + warning_box(TR("Pensi di avere selezionato qualcosa??")); else { pag=m.get_int(101); if(pag==0) { - warning_box("La pagina 0 non esiste! "\ - "Lascio tutto ancora nella stessa pagina."); + warning_box(TR("La pagina 0 non esiste! Lascio tutto ancora nella stessa pagina.")); pag=_page; } else @@ -2691,7 +2690,7 @@ void TEditMask_window::handler(WINDOW win, EVENT *ep) const PNT& p = ep->v.mouse.where; bool intool; const PNT pnt=logic(p, intool); - s.format("Coordinate:%3d,%3d", pnt.h , pnt.v); + s.format(FR("Coordinate:%3d,%3d"), pnt.h , pnt.v); xvt_statbar_set(s); if(win) selected_crt(win,ep); @@ -2701,7 +2700,7 @@ void TEditMask_window::handler(WINDOW win, EVENT *ep) { TString16 p; o_key(e_char_to_key(ep)); - p.format("Pag.%d",_page); + p.format(FR("Pag.%d"),_page); xvt_statbar_set(p); set_caption(_name.row(_page)); } @@ -3002,7 +3001,7 @@ TEditMask_control* TEditMask_window::read_control(TScanner& scanner,const TStrin void TEditMask_window::read_page(TScanner& scanner, int pg,bool tool) { if(!tool) - _name.add("Maschera",0); + _name.add(TR("Maschera"),0); _page=_total_page=pg; _name.add(scanner.string(),_page); set_caption(_name.row(_page)); @@ -3105,7 +3104,7 @@ void TEditMask_window::save_as_mask() strcpy(fs.creator, "ba2"); xvt_fsys_get_default_dir(&fs.dir); - if (xvt_dm_post_file_save(&fs, "Salva con nome:")== FL_OK) + if (xvt_dm_post_file_save(&fs, TR("Salva con nome:"))== FL_OK) { xvt_fsys_set_dir(&fs.dir); _file=fs.name; @@ -3154,7 +3153,7 @@ void TEditMask_window::vision_spread() //Visualizza tutti i controlli presenti nella pagina corrente void TEditMask_window::vision_ctrl() { - TArray_sheet elenco(-1,-1,76,20,"Elenco dei controlli","Tipo@15|Identificativo@15|Prompt@25|Pagina@8|Flags@10", 0x4); + TArray_sheet elenco(-1,-1,76,20,TR("Elenco dei controlli"), HR("Tipo@15|Identificativo@15|Prompt@25|Pagina@8|Flags@10"), 0x4); for(int i=0;i<_controls.items() ;i++) { @@ -3241,7 +3240,7 @@ void TMaskEditor_application::new_mask() { destroy_window(); - _window = new TEditMask_window(-1,-1,78,20,"Maschera", WSF_SIZE,W_DOC); + _window = new TEditMask_window(-1,-1,78,20,TR("Maschera"), WSF_SIZE,W_DOC); _window->open(); _dirty = TRUE; @@ -3253,7 +3252,7 @@ void TMaskEditor_application::open_mask() TFilename in; - if (_dirty && _save && yesno_box("Salvare la maschera corrente?")) + if (_dirty && _save && yesno_box(TR("Salvare la maschera corrente?"))) save_as_mask(); _dirty = _save = FALSE; @@ -3265,7 +3264,7 @@ void TMaskEditor_application::open_mask() strcpy(fs.name, ""); strcpy(fs.creator, "ba2"); xvt_fsys_get_default_dir(&fs.dir); - if (xvt_dm_post_file_open(&fs, "Apri file:") == FL_OK) //apre solo virtualmente + if (xvt_dm_post_file_open(&fs, TR("Apri file:")) == FL_OK) //apre solo virtualmente { xvt_fsys_set_dir(&fs.dir); in=fs.name; @@ -3275,13 +3274,13 @@ void TMaskEditor_application::open_mask() if(!in.exist()) { - xvt_dm_post_error("Il file non può essere aperto... non esiste!"); + xvt_dm_post_error((char *)TR("Il file non può essere aperto... non esiste!")); return; } else { destroy_window(); - _window = new TEditMask_window(-1,-1,68,16,"Maschera", WSF_SIZE,W_DOC); + _window = new TEditMask_window(-1,-1,68,16,TR("Maschera"), WSF_SIZE,W_DOC); _save=TRUE; _window->set_mod(FALSE); _window->open(); @@ -3490,6 +3489,6 @@ bool TMaskEditor_application::menu(MENU_TAG m) int ba2600(int argc, char* argv[]) { TMaskEditor_application a; - a.run(argc, argv, "Editor di maschere"); + a.run(argc, argv, TR("Editor di maschere")); return 0; } diff --git a/ba/ba3100.cpp b/ba/ba3100.cpp index eec8842c9..7bfcb0ea3 100755 --- a/ba/ba3100.cpp +++ b/ba/ba3100.cpp @@ -216,7 +216,7 @@ HIDDEN bool tiporeg_handler(TMask_field& f, KEY k) if ((k == K_TAB || k == K_ENTER) && app().exist_journal() && (atoi(f.get()) == REG_JOURNAL) ) - return f.error_box("Non e' possibile avere due registri giornale nello stesso anno"); + return f.error_box(TR("Non e' possibile avere due registri giornale nello stesso anno")); return TRUE; } @@ -244,7 +244,7 @@ HIDDEN bool printer_handler(TMask_field& f, KEY k) p.read_configuration(); } else - return f.error_box("Nessun registro selezionato"); + return f.error_box(TR("Nessun registro selezionato")); } } return TRUE; @@ -321,7 +321,7 @@ HIDDEN bool coddel_handler(TMask_field& f, KEY k) if (!titcf) { m.hide(F_CONCESSIONE); - f.error_box("Concessione non ammessa senza conto fiscale"); + f.error_box(TR("Concessione non ammessa senza conto fiscale")); } else { @@ -354,14 +354,14 @@ HIDDEN bool intdel_handler(TMask_field& f, KEY k) TConfig cnf(CONFIG_DITTA, "cg"); bool isintr = cnf.get_bool("InTrTr"); if (isintr) - return f.error_box("Interessi non ammessi: ditta con NO calcolo interessi"); + return f.error_box(TR("Interessi non ammessi: ditta con NO calcolo interessi")); } - else return f.error_box("Interessi non ammessi: ditta con versamenti mensili"); + else return f.error_box(TR("Interessi non ammessi: ditta con versamenti mensili")); if (imp < intr) - return f.error_box("Incoerenza importo versato e interessi"); + return f.error_box(TR("Incoerenza importo versato e interessi")); else if (!imp.is_zero() && imp == intr) - return f.error_box("Incoerenza importo versato e interessi"); + return f.error_box(TR("Incoerenza importo versato e interessi")); } return TRUE; } @@ -392,7 +392,7 @@ HIDDEN bool impdel_handler(TMask_field& f, KEY k) real lim; if (ver.read(m.get_int(F_ANNODEL), (mese_del>12) ? 12 : mese_del) != NOERR) - warning_box("Errore %d in lettura tabella versamenti ed interessi.",ver.status()); + warning_box(FR("Errore %d in lettura tabella versamenti ed interessi."),ver.status()); if (tipo_del == 1) { if (mese_del == 12) lim = ver.get(I_ANNUALE); @@ -401,7 +401,7 @@ HIDDEN bool impdel_handler(TMask_field& f, KEY k) else lim = ver.get(I_ACCONTOIVA); const real imp(m.get(F_IMPORTO)); if (imp < lim) - return f.yesno_box("Importo inferiore a %s. Registrare ugualmente?", lim.string(".")); + return f.yesno_box(FR("Importo inferiore a %s. Registrare ugualmente?"), lim.string(".")); } } return TRUE; @@ -446,14 +446,14 @@ HIDDEN bool mese_handler(TMask_field& f, KEY k) { TMask* mask = &m; mask->reset(); - return f.error_box("Ditta trimestrale: indicare trimestre"); + return f.error_box(TR("Ditta trimestrale: indicare trimestre")); } } else if (mese != 3 && mese != 6 && mese != 9 && mese != 13) { TMask* mask = &m; mask->reset(); - return f.error_box("Ditta trimestrale: indicare trimestre"); + return f.error_box(TR("Ditta trimestrale: indicare trimestre")); } } } @@ -541,7 +541,7 @@ bool TGeneric_table_app::codcab_handler(TMask_field& f, KEY k) const TString& abi = m.get(f.dlg()-1); const TRectype& rec = cache().get(TAB_BANCHE, abi); if (rec.empty()) - return f.error_box("Il codice ABI %s non esiste", (const char*)abi); + return f.error_box(FR("Il codice ABI %s non esiste"), (const char*)abi); } return TRUE; } @@ -631,6 +631,6 @@ int TGeneric_table_app::rewrite(const TMask& m) int ba3100(int argc, char* argv[]) { TGeneric_table_app a; - a.run(argc, argv, "Tabella"); + a.run(argc, argv, TR("Tabella")); return 0; } diff --git a/ba/ba3200.cpp b/ba/ba3200.cpp index 1831f96ed..360bc8727 100755 --- a/ba/ba3200.cpp +++ b/ba/ba3200.cpp @@ -230,7 +230,7 @@ void BA3200_application::set_headers() ragsoc = nditte.get(NDT_RAGSOC); if (LungRiga < 100) ragsoc.cut(40); } - riga.overwrite(format("Ditta %4ld %s", codditta,(const char *)ragsoc)); + riga.overwrite(format(FR("Ditta %4ld %s"), codditta,(const char *)ragsoc)); } if (_stampa_ca7) @@ -239,7 +239,7 @@ void BA3200_application::set_headers() printer().setdate(d); } - riga.overwrite ("Data @> Pag. @#", riga.len()-25); + riga.overwrite (FR("Data @> Pag. @#"), riga.len()-25); set_header (last_riga++, "%s", (const char *)riga); @@ -444,7 +444,7 @@ bool BA3200_application::user_create() t = _tabname.right(3); _maskname << get_mask_name(t) << ".msk"; if (!_maskname.exist()) - ok = error_box("Impossibile aprire la maschera di stampa %s", (const char *)_maskname); + ok = error_box(FR("Impossibile aprire la maschera di stampa %s"), (const char *)_maskname); else _msk = new TMask (_maskname) ; if (ok) @@ -452,7 +452,7 @@ bool BA3200_application::user_create() t = _tabname.right(3); _rptname << get_rpt_name(t) << ".rpt" ; if (!_rptname.exist()) - ok = error_box("Impossibile aprire il report di stampa %s", (const char *)_rptname); + ok = error_box(FR("Impossibile aprire il report di stampa %s"), (const char *)_rptname); else { _rpt = new TScanner(_rptname); @@ -503,6 +503,6 @@ bool BA3200_application::user_destroy() int ba3200(int argc, char* argv[]) { BA3200_application a; - a.run(argc, argv, "Stampa tabella"); + a.run(argc, argv, TR("Stampa tabella")); return 0; } diff --git a/ba/ba3300.cpp b/ba/ba3300.cpp index 80dcaef04..dce6ebd21 100755 --- a/ba/ba3300.cpp +++ b/ba/ba3300.cpp @@ -65,7 +65,7 @@ print_action Libribollati_print::postprocess_page(int, int counter) bool Libribollati_print::preprocess_print(int, int) { - _p = new TProgind(_pag_fin-_pag_ini+1, "Preparazione stampa", FALSE, TRUE, 60); + _p = new TProgind(_pag_fin-_pag_ini+1, TR("Preparazione stampa"), FALSE, TRUE, 60); return TRUE; } @@ -101,9 +101,9 @@ void Libribollati_print::set_page(int , int counter) if (!_inizia_dopo) { if (_anno_stampa == 0) - set_row(3, "@120gPag. %ld", contatore); + set_row(3, FR("@120gPag. %ld"), contatore); else - set_row(3, "@120gPag. %4d/%ld", _anno_stampa, contatore); + set_row(3, FR("@120gPag. %4d/%ld"), _anno_stampa, contatore); } int pos = printer().formlen() / 2 - 3; set_row(pos++, "@36g%-50s", (const char*) _descr); @@ -115,8 +115,8 @@ void Libribollati_print::set_page(int , int counter) s = _capulc; s << " " << _com << " " << _prov; set_row(pos++, "@36g%-62s", (const char*) s); - set_row(pos++, "@36gCODICE FISCALE %-16s", (const char*)_cofi); - set_row(pos, "@36gPARTITA I.V.A. %-11s", (const char*) _paiv); + set_row(pos++, FR("@36gCODICE FISCALE %-16s"), (const char*)_cofi); + set_row(pos, FR("@36gPARTITA I.V.A. %-11s"), (const char*) _paiv); } else if (counter == _num_pag - 1) @@ -127,14 +127,14 @@ void Libribollati_print::set_page(int , int counter) s << " " << _civulc << " " << _capulc << " " << _com << " " << _prov; set_row(1, "@62g%-65s", (const char*) s); set_row(2, "@1g%-50s", (const char*) _descr); - set_row(2, "@52gCODICE FISCALE %-16s", (const char*) _cofi); - set_row(2, "@85gPARTITA I.V.A. %-11s", (const char*) _paiv); + set_row(2, FR("@52gCODICE FISCALE %-16s"), (const char*) _cofi); + set_row(2, FR("@85gPARTITA I.V.A. %-11s"), (const char*) _paiv); if (_anno_stampa == 0) - set_row(2, "@120gPag. %ld", contatore); + set_row(2, FR("@120gPag. %ld"), contatore); else - set_row(2, "@120gPag. %4d/%ld", _anno_stampa, contatore); - set_row(25, "@50gN. ........ DI REPERTORIO"); - set_row(27, "@50gIL PRESENTE LIBRO DELLA@75g%-50s", (const char*) _ragsoc); + set_row(2, FR("@120gPag. %4d/%ld"), _anno_stampa, contatore); + set_row(25, FR("@50gN. ........ DI REPERTORIO")); + set_row(27, FR("@50gIL PRESENTE LIBRO DELLA@75g%-50s"), (const char*) _ragsoc); s = _indulc; s << " " << _civulc; @@ -142,8 +142,8 @@ void Libribollati_print::set_page(int , int counter) s = _capulc; s << " " << _com << " " << _prov; set_row(31, "@50g%-62s", (const char*) s); - set_row(33, "@50gCONSTA DI %ld PAGINE UTILI, BOLLATE E NUMERATE", _num_pag - (_inizia_dopo ? 1 : 0)); - set_row(35, "@50gE VIENE OGGI VIDIMATO, il ........."); + set_row(33, FR("@50gCONSTA DI %ld PAGINE UTILI, BOLLATE E NUMERATE"), _num_pag - (_inizia_dopo ? 1 : 0)); + set_row(35, FR("@50gE VIENE OGGI VIDIMATO, il .........")); } else { @@ -153,12 +153,12 @@ void Libribollati_print::set_page(int , int counter) s << " " << _civulc << " " << _capulc << " " << _com << " " << _prov; set_row(1, "@52g%-68s", (const char*) s); set_row(2, "@1g%-50s", (const char*) _descr); - set_row(2, "@52gCODICE FISCALE %-16s", (const char*) _cofi); - set_row(2, "@85gPARTITA I.V.A. %-11s", (const char*) _paiv); + set_row(2, FR("@52gCODICE FISCALE %-16s"), (const char*) _cofi); + set_row(2, FR("@85gPARTITA I.V.A. %-11s"), (const char*) _paiv); if (_anno_stampa == 0) - set_row(2, "@120gPag. %ld", contatore); + set_row(2, FR("@120gPag. %ld"), contatore); else - set_row(2, "@120gPag. %4d/%ld", _anno_stampa, contatore); + set_row(2, FR("@120gPag. %4d/%ld"), _anno_stampa, contatore); } } @@ -182,8 +182,7 @@ bool Libribollati_print::set_print(int) int font_size = pr.calc_font_size(132); if (font_size != pr.get_char_size()) { - warning_box("Il font e' stato ridimensionato a %d punti per\n" - "adattarsi alle dimensioni attuali della pagina.", font_size); + warning_box(FR("Il font e' stato ridimensionato a %d punti per\nadattarsi alle dimensioni attuali della pagina."), font_size); pr.set_char_size(font_size); } _cod_reg = _msk->get(F_CODICE); @@ -240,7 +239,7 @@ static bool codditta_handler(TMask_field& field, KEY key) nditte.put(N_CODDITTA, codditta); nditte.read(); if (nditte.bad()) - return field.error_box("Il codice ditta %d non esiste", codditta); + return field.error_box(FR("Il codice ditta %d non esiste"), codditta); const bool exist_firm = prefix().exist(codditta); if (exist_firm) app().set_firm(codditta); @@ -332,6 +331,6 @@ bool Libribollati_print::user_destroy() int ba3300(int argc, char* argv[]) { Libribollati_print a; - a.run(argc, argv, "Stampa fogli libri bollati"); + a.run(argc, argv, TR("Stampa fogli libri bollati")); return 0; } diff --git a/ba/ba3400.cpp b/ba/ba3400.cpp index 8b32e9a7c..11543bb39 100755 --- a/ba/ba3400.cpp +++ b/ba/ba3400.cpp @@ -93,11 +93,6 @@ bool TTest_application::menu(MENU_TAG) int ba3400(int argc, char* argv[]) { TApplication::check_parameters(argc, argv); -// if (argc < 3) -// { -// error_box("You should specify a mask"); -// return 1; -// } if (argc <= 3) { @@ -107,7 +102,7 @@ int ba3400(int argc, char* argv[]) else { TTestrel_application a(argv[2], argv[3]); - a.run(argc, argv, "Gestione archivi"); + a.run(argc, argv, TR("Gestione archivi")); } return 0; } diff --git a/ba/ba3500.cpp b/ba/ba3500.cpp index 7e9c6b2df..7ac24f33a 100755 --- a/ba/ba3500.cpp +++ b/ba/ba3500.cpp @@ -397,7 +397,7 @@ bool BA3500_application::user_destroy() int ba3500(int argc, char* argv[]) { BA3500_application a; - a.run(argc, argv, "Tabella libro unico"); + a.run(argc, argv, TR("Tabella libro unico")); return 0; } diff --git a/ba/ba3600.cpp b/ba/ba3600.cpp index 4760cfbf5..bd13bc02d 100755 --- a/ba/ba3600.cpp +++ b/ba/ba3600.cpp @@ -137,7 +137,7 @@ void TStampa_indici::crea_sort() const TRectype rec(_indlib->curr()); - for (_indlib->read(); !_indlib->eof(); _indlib->next()) + for (_indlib->read(_isgteq); !_indlib->eof(); _indlib->next()) { if (_indlib->curr() > rec) break; @@ -212,7 +212,7 @@ void TStampa_indici::crea_sort() } //su bollato (flag = TRUE). else { - error_box("La stampa su bollato e' gia' stata effettuata!"); + error_box(TR("La stampa su bollato e' gia' stata effettuata!")); } _ho_stampato_almeno_un_bollato = stampato; } @@ -458,14 +458,14 @@ void TStampa_indici::setta_righe_prova() set_row (i, "@13g#5d", &_numfin_paglib); if ((_pag_ann) && (_codditta == 0)) - set_row (i,"@27gPAGINE ANNULLATE"); + set_row (i,FR("@27gPAGINE ANNULLATE")); else { set_row (i,"@21g#5ld", &_codditta); set_row (i,"@27g#.41t", &_rag_soc); } if ((_pag_ann) && (_codditta != 0) && (_cod_reg == "")) - set_row (i,"@73gPAGINE ANNULLATE"); + set_row (i,FR("@73gPAGINE ANNULLATE")); else { set_row (i,"@69g#t", &_cod_reg); @@ -493,14 +493,14 @@ void TStampa_indici::setta_righe_bollato() set_row (i,"@13g#5d", &_numfin_paglib); if ((_pag_ann) && (_codditta == 0)) - set_row (i,"@27gPAGINE ANNULLATE"); + set_row (i,FR("@27gPAGINE ANNULLATE")); else { set_row (i,"@21g#5ld", &_codditta); set_row (i,"@27g#.41t", &_rag_soc); } if ((_pag_ann) && (_codditta != 0) && (_cod_reg == "")) - set_row (i,"@73gPAGINE ANNULLATE"); + set_row (i,FR("@73gPAGINE ANNULLATE")); else { set_row (i,"@69g#t", &_cod_reg); @@ -630,29 +630,29 @@ void TStampa_indici::crea_intestazione_prova() reset_header(); - set_header (1,"Studio %s %s %s %s %s %s", (const char*) ragsoc,(const char*) ind,(const char*) civ, + set_header (1,FR("Studio %s %s %s %s %s %s"), (const char*) ragsoc,(const char*) ind,(const char*) civ, (const char*) cap,(const char*) com,(const char*) prov); - sep << "Pag. @#"; + sep << FR("Pag. @#"); sep.right_just(132); set_header (2,(const char*) sep); datastampastr = _datastampa.string(); - set_header (2,"@0gPartita iva %11s", (const char*) paiv); - set_header (2,"@30gCodice fiscale %16s", (const char*) cofi); - set_header (2,"@75gLIBRO UNICO DI PROVA"); - set_header (2,"@105gData@110g%s",(const char*) datastampastr); + set_header (2, FR("@0gPartita iva %11s"), (const char*) paiv); + set_header (2, FR("@30gCodice fiscale %16s"), (const char*) cofi); + set_header (2, FR("@75gLIBRO UNICO DI PROVA")); + set_header (2, FR("@105gData@110g%s"),(const char*) datastampastr); - set_header (3,"@0gLibro unico : %s %s", (const char*) _cod_lib,(const char*) _desc_cod_lib); + set_header (3,FR("@0gLibro unico : %s %s"), (const char*) _cod_lib,(const char*) _desc_cod_lib); TString mese = itom(_mese); - set_header (3,"@75gmese di %s", (const char*) mese); + set_header (3,FR("@75gmese di %s"), (const char*) mese); set_header (3,"@92g%4d", _anno); sep.fill('-'); //Stampa 132 - (sep(132)) set_header (4, (const char *) sep); - set_header (5,"@0gCod.@6gNumero@13gpagine@21gCodice@69gCod.@104gCodice@111gN.pag.@118gutente@126gNum.@131gS"); - set_header (6,"@0gLibro@8gda@16ga@21gditta@28gDenominazione@69greg.@74gDescrizione@104gvidim.@112gutilizzate@126greg.@131gB"); + set_header (5, FR("@0gCod.@6gNumero@13gpagine@21gCodice@69gCod.@104gCodice@111gN.pag.@118gutente@126gNum.@131gS")); + set_header (6, FR("@0gLibro@8gda@16ga@21gditta@28gDenominazione@69greg.@74gDescrizione@104gvidim.@112gutilizzate@126greg.@131gB")); set_header (7, (const char *) sep); } @@ -679,21 +679,21 @@ void TStampa_indici::crea_intestazione_bollato() intestatario(cofi,paiv,ragsoc,ind,civ,cap,com,prov); compatta_ragsoc(ragsoc); - set_header (1,"Studio %s %s %s %s %s %s", (const char*) ragsoc,(const char*) ind,(const char*) civ, + set_header (1, FR("Studio %s %s %s %s %s %s"), (const char*) ragsoc,(const char*) ind,(const char*) civ, (const char*) cap,(const char*) com,(const char*) prov); - set_header (2,"@0gPartita iva %11s", (const char*) paiv); - set_header (2,"@30gCodice fiscale %16s", (const char*) cofi); + set_header (2, FR("@0gPartita iva %11s"), (const char*) paiv); + set_header (2, FR("@30gCodice fiscale %16s"), (const char*) cofi); } - set_header (3,"@0gLibro unico : %s %s", (const char*) _cod_lib_su,(const char*) _desc_cod_lib_su); + set_header (3, FR("@0gLibro unico : %s %s"), (const char*) _cod_lib_su,(const char*) _desc_cod_lib_su); TString mese = itom(_mese); - set_header (3,"@75gmese di %s", (const char*) mese); + set_header (3, FR("@75gmese di %s"), (const char*) mese); set_header (3,"@92g%4d", _anno); sep.fill('-'); //Stampa 132 - (sep(132)) set_header (4, (const char *) sep); - set_header (5,"@0gCod.@6gNumero@13gpagine@21gCodice@69gCod.@104gCodice@111gN.pag.@118gutente"); - set_header (6,"@0gLibro@8gda@16ga@21gditta@28gDenominazione@69greg.@74gDescrizione@104gvidim.@112gutilizzate"); + set_header (5,FR("@0gCod.@6gNumero@13gpagine@21gCodice@69gCod.@104gCodice@111gN.pag.@118gutente")); + set_header (6,FR("@0gLibro@8gda@16ga@21gditta@28gDenominazione@69greg.@74gDescrizione@104gvidim.@112gutilizzate")); set_header (7, (const char *) sep); } @@ -734,12 +734,12 @@ int ba3600 (int argc, char* argv[]) if (*argv[2] == 'A') { Stp_indici_LUnico b; - b.run(argc, argv, "Stampa indici libro unico per ditta"); + b.run(argc, argv, TR("Stampa indici libro unico per ditta")); } else { TStampa_indici a; - a.run(argc, argv, "Stampa indici registro libro unico"); + a.run(argc, argv, TR("Stampa indici registro libro unico")); } return 0; } diff --git a/ba/ba3601.cpp b/ba/ba3601.cpp index 60072761c..767c1b2c9 100755 --- a/ba/ba3601.cpp +++ b/ba/ba3601.cpp @@ -38,10 +38,10 @@ bool Stp_indici_LUnico::registri_ditta_hnd(TMask_field& f, KEY k) bool trovato = FALSE; long ditta = f.mask().get_long(F_CODDITTA); if (ditta == 0) - return f.error_box("La ditta e' obbligatoria"); + return f.error_box(TR("La ditta e' obbligatoria")); long old_dta = a().get_firm(); TString cod_lu = f.mask().get(F_LIBRO_UNICO1); - if (!prefix().exist(ditta)) return f.error_box("La ditta %ld non ha nessun registro",ditta); + if (!prefix().exist(ditta)) return f.error_box(FR("La ditta %ld non ha nessun registro"),ditta); a().set_firm(ditta); int anno = f.mask().get_int(F_ANNO); TTable reg ("REG"); @@ -64,7 +64,7 @@ bool Stp_indici_LUnico::registri_ditta_hnd(TMask_field& f, KEY k) } a().set_firm(old_dta); if (!trovato) - return f.error_box("La ditta %ld per l'anno %d non ha registri che vengono stampati sul libro unico", ditta, anno); + return f.error_box(FR("La ditta %ld per l'anno %d non ha registri che vengono stampati sul libro unico"), ditta, anno); } return TRUE; } @@ -331,7 +331,7 @@ void Stp_indici_LUnico::set_page(int file, int counter) set_row (i, "@35g#5d", &_numfin_paglib); if (_pag_ann && _cod_reg == "") - set_row (i,"@53gPAGINE ANNULLATE"); + set_row (i,FR("@53gPAGINE ANNULLATE")); else { set_row (i,"@50g#t", &_cod_reg); @@ -359,34 +359,34 @@ void Stp_indici_LUnico::print_header() compatta_ragsoc(_ragsoc); // Dati studio if (_ragsoc.len() > 50) _ragsoc.cut(50); - set_header (1,"Studio %-50s @60g%s @110g%s @116g%-13s @129g%s", + set_header (1,FR("Studio %-50s @60g%s @110g%s @116g%-13s @129g%s"), (const char*)_ragsoc, (const char*)ind, (const char*)_cap, (const char*)_com, (const char*)_prov); - sep << "Pag. @#"; + sep << FR("Pag. @#"); sep.right_just(132); set_header (2,(const char*) sep); - set_header (2,"@0gPartita iva %-11s", (const char*)_paiv); - set_header (2,"@26gCodice fiscale %-16s", (const char*)_cofi); - set_header (2,"@105gData %s",(const char*) _datastampa.string()); - set_header (3,"@0gLibro unico : %s %s", (const char*)_codlib, (const char*)_desc_cod_lib); - set_header (3,"@70gANNO %4d", _anno); + set_header (2,FR("@0gPartita iva %-11s"), (const char*)_paiv); + set_header (2,FR("@26gCodice fiscale %-16s"), (const char*)_cofi); + set_header (2,FR("@105gData %s"),(const char*) _datastampa.string()); + set_header (3,FR("@0gLibro unico : %s %s"), (const char*)_codlib, (const char*)_desc_cod_lib); + set_header (3,FR("@70gANNO %4d"), _anno); sep.fill('-'); set_header(4, (const char *) sep); // Dati ditta ind = _ind_dta; ind << ", " << _civ_dta; if (_ragsoc_dta.len() > 45) _ragsoc_dta.cut(45); - set_header(5,"Ditta %05ld %-45s @60g%s @110g%s @116g%-13s @129g%s", + set_header(5,FR("Ditta %05ld %-45s @60g%s @110g%s @116g%-13s @129g%s"), _ditta,(const char*)_ragsoc_dta,(const char*) ind,(const char*)_cap_dta, (const char*)_com_dta,(const char*)_prov_dta); - set_header(6,"@0gPartita iva %-11s", (const char*)_paiv_dta); - set_header(6,"@26gCodice fiscale %-16s", (const char*)_cofi_dta); + set_header(6,FR("@0gPartita iva %-11s"), (const char*)_paiv_dta); + set_header(6,FR("@26gCodice fiscale %-16s"), (const char*)_cofi_dta); set_header(7, (const char *) sep); // Intestazione colone - set_header(8,"@20g---- Libro Unico ----"); - set_header(8,"@50g------------------------------"); - set_header(8,"@81gRegistri della ditta"); + set_header(8,FR("@20g---- Libro Unico ----")); + set_header(8,FR("@50g------------------------------")); + set_header(8,FR("@81gRegistri della ditta")); set_header(8,"@102g------------------------------"); - set_header (9,"Mese @20gVidim. Da pag A pag @50gCod Descrizione @84gDa pag A pag"); + set_header (9,FR("Mese @20gVidim. Da pag A pag @50gCod Descrizione @84gDa pag A pag")); set_header (10, (const char *) sep); } diff --git a/ba/ba3700.cpp b/ba/ba3700.cpp index e890029e3..be48f3a81 100755 --- a/ba/ba3700.cpp +++ b/ba/ba3700.cpp @@ -322,14 +322,14 @@ bool TCond_pag_app::fixed_scad(TMask_field& f, KEY k) const int prev_val = f.mask().get_int(fld_arr[i -1]); if (val != 0 && (prev_val == 0 || prev_val >= val)) - return f.error_box("Giorno non in sequenza"); + return f.error_box(TR("Giorno non in sequenza")); } if (k != K_ENTER && i < 2) { const int next_val = f.mask().get_int(fld_arr[i + 1]); if (next_val != 0 && next_val < val) - return f.error_box("Giorno non in sequenza"); + return f.error_box(TR("Giorno non in sequenza")); } pag->set_fixed_scad(val, i); @@ -561,6 +561,6 @@ void TCond_pag_app::sheet2ini(TSheet_field &sheet,TConfig& ini) int ba3700(int argc, char* argv[]) { TCond_pag_app a; - a.run(argc, argv, "Condizioni di pagamento"); + a.run(argc, argv, TR("Condizioni di pagamento")); return 0; } diff --git a/ba/ba3800.cpp b/ba/ba3800.cpp index 0249700ff..3cd5951fb 100755 --- a/ba/ba3800.cpp +++ b/ba/ba3800.cpp @@ -367,7 +367,7 @@ void BA3800_application::totale_numero_arabo() //Fai il totale del numero arabo e stampalo if (_num != 0) { - set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i,FR("@18gTotale@25g%2d@27g)"), _num); set_row (_i++,"@86g%s", (const char*) _totale); } } @@ -382,7 +382,7 @@ void BA3800_application::totale_numero_romano() TString numrom = itor(numeror); if (numrom != "") { - set_row (_i,"@14gTotale@21g%s", (const char*) numrom); + set_row (_i, FR("@14gTotale@21g%s"), (const char*) numrom); set_row (_i++,"@86g%s", (const char*) _totale); } } @@ -395,7 +395,7 @@ void BA3800_application::totale_lettera() //Fai il totale della lettera e stampalo if (_let != ' ') { - set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i,FR("@3gTotale@10g%c@12g)"), _let); set_row (_i++,"@86g%s", (const char*) _totale); } } @@ -436,9 +436,9 @@ void BA3800_application::stampa_totali_studio() { if (_num_tot == "20" || _num_tot == "21") { - set_row (_i,"@4gTotale delle partite straordinarie"); + set_row (_i, FR("@4gTotale delle partite straordinarie")); set_row (_i++,"@86g%s", (const char*) _totale); - set_row (_i,"@4gRisultato prima delle imposte"); + set_row (_i,FR("@4gRisultato prima delle imposte")); set_row (_i++,"@86g%s", (const char*) _totale); _risimp_fatto = FALSE; } @@ -469,14 +469,14 @@ void BA3800_application::stampa_totali_studio() { //Fai il totale della lettera e stampalo if (_let_stamp == 'D') - set_row (_i,"@4gTotale delle rettifiche"); + set_row (_i,FR("@4gTotale delle rettifiche")); else if (_let != ' ') if (_sez_stamp == '9' && _let_stamp != 'E') - set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i, FR("@3gTotale@10g%c@12g)"), _let); else if (_sez_stamp != '9') - set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i,FR("@3gTotale@10g%c@12g)"), _let); if (_let != ' ') { if (_sez_stamp == '9' && _let_stamp != 'E') @@ -491,7 +491,7 @@ void BA3800_application::stampa_totali_studio() { if (_let_tot == 'A' || _let_tot == 'B') //Solo se esiste una delle due lettere { - set_row (_i++,"@4gDifferenza tra valore e costi della produzione@86g%s", (const char*) _totale); + set_row (_i++,FR("@4gDifferenza tra valore e costi della produzione@86g%s"), (const char*) _totale); _diffprod_fatto = FALSE; } } @@ -519,13 +519,13 @@ void BA3800_application::stampa_totali_studio() { if (_sez_stamp == '9' && _let_stamp != 'E') { - set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i,FR("@3gTotale@10g%c@12g)"), _let); set_row (_i++,"@86g%s", (const char*) _totale); } else if (_sez_stamp != '9') { - set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i,FR("@3gTotale@10g%c@12g)"), _let); set_row (_i++,"@86g%s", (const char*) _totale); } } @@ -534,7 +534,7 @@ void BA3800_application::stampa_totali_studio() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE ATTIVO"); + set_row (_i, FR("@0gTOTALE ATTIVO")); set_row (_i++,"@86g%s", (const char*) _totale); } @@ -542,7 +542,7 @@ void BA3800_application::stampa_totali_studio() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE PASSIVO"); + set_row (_i, FR("@0gTOTALE PASSIVO")); set_row (_i++,"@86g%s", (const char*) _totale); } @@ -550,8 +550,8 @@ void BA3800_application::stampa_totali_studio() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gSALDO STATO PATRIMONIALE"); - set_row (_i,"@0gSBILANCIO (ATTIVO - PASSIVO)"); + set_row (_i++, FR("@0gSALDO STATO PATRIMONIALE")); + set_row (_i, FR("@0gSBILANCIO (ATTIVO - PASSIVO)")); set_row (_i++,"@86g%s", (const char*) _totale); } @@ -561,19 +561,19 @@ void BA3800_application::stampa_totali_studio() { if ((_let_stamp == 'A' || _let_stamp == 'B') && _diffprod_fatto)//Solo se esiste una delle due lettere { - set_row (_i++,"@4gDifferenza tra valore e costi della produzione@86g%s", (const char*) _totale); + set_row (_i++, FR("@4gDifferenza tra valore e costi della produzione@86g%s"), (const char*) _totale); _diffprod_fatto = FALSE; } if (_risimp_fatto) { - set_row (_i,"@4gRisultato prima delle imposte"); + set_row (_i, FR("@4gRisultato prima delle imposte")); set_row (_i++,"@86g%s", (const char*) _totale); } } char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gRISULTATO CONTO ECONOMICO"); + set_row (_i,FR("@0gRISULTATO CONTO ECONOMICO")); set_row (_i++,"@86g%s", (const char*) _totale); } _cont_gcs = 0; @@ -617,7 +617,7 @@ void BA3800_application::stampa_totali_ditta() //Fai il totale del numero arabo e stampalo if (_num != 0) { - set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i, FR("@18gTotale@25g%2d@27g)"), _num); set_row (_i++,"@86g%s", (const char*) _totale); } } @@ -632,9 +632,9 @@ void BA3800_application::stampa_totali_ditta() { if (_num_tot == "20" || _num_tot == "21") { - set_row (_i,"@4gTotale delle partite straordinarie"); + set_row (_i, FR("@4gTotale delle partite straordinarie")); set_row (_i++,"@86g%s", (const char*) _totale); - set_row (_i,"@4gRisultato prima delle imposte"); + set_row (_i, FR("@4gRisultato prima delle imposte")); set_row (_i++,"@86g%s", (const char*) _totale); _risimp_fatto = FALSE; } @@ -654,7 +654,7 @@ void BA3800_application::stampa_totali_ditta() //Fai il totale del numero arabo e stampalo if (_num != 0) { - set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i, FR("@18gTotale@25g%2d@27g)"), _num); set_row (_i++,"@86g%s", (const char*) _totale); } } @@ -665,7 +665,7 @@ void BA3800_application::stampa_totali_ditta() TString numrom = itor(numeror); if (numrom != "") { - set_row (_i,"@14gTotale@21g%s", (const char*) numrom); + set_row (_i,FR("@14gTotale@21g%s"), (const char*) numrom); set_row (_i++,"@86g%s", (const char*) _totale); } } @@ -687,7 +687,7 @@ void BA3800_application::stampa_totali_ditta() //Fai il totale del numero arabo e stampalo if (_num != 0) { - set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i,FR("@18gTotale@25g%2d@27g)"), _num); set_row (_i++,"@86g%s", (const char*) _totale); } } @@ -698,7 +698,7 @@ void BA3800_application::stampa_totali_ditta() TString numrom = itor(numeror); if (numrom != "") { - set_row (_i,"@14gTotale@21g%s", (const char*) numrom); + set_row (_i, FR("@14gTotale@21g%s"), (const char*) numrom); set_row (_i++,"@86g%s", (const char*) _totale); } } @@ -706,14 +706,14 @@ void BA3800_application::stampa_totali_ditta() { //Fai il totale della lettera e stampalo if (_let_stamp == 'D') - set_row (_i,"@4gTotale delle rettifiche"); + set_row (_i, FR("@4gTotale delle rettifiche")); else if (_let != ' ') if (_sez_stamp == '9' && _let_stamp != 'E') - set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i,FR("@3gTotale@10g%c@12g)"), _let); else if (_sez_stamp != '9') - set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i,FR("@3gTotale@10g%c@12g)"), _let); if (_let != ' ') { if (_sez_stamp == '9' && _let_stamp != 'E') @@ -728,7 +728,7 @@ void BA3800_application::stampa_totali_ditta() { if (_let_tot == 'A' || _let_tot == 'B') //Solo se esiste una delle due lettere { - set_row (_i++,"@4gDifferenza tra valore e costi della produzione@86g%s", (const char*)_totale); + set_row (_i++, FR("@4gDifferenza tra valore e costi della produzione@86g%s"), (const char*)_totale); _diffprod_fatto = FALSE; } } @@ -744,7 +744,7 @@ void BA3800_application::stampa_totali_ditta() //Fai il totale del numero arabo e stampalo if (_num != 0) { - set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i,FR("@18gTotale@25g%2d@27g)"), _num); set_row (_i++,"@86g%s", (const char*) _totale); } } @@ -755,7 +755,7 @@ void BA3800_application::stampa_totali_ditta() TString numrom = itor(numeror); if (numrom != "") { - set_row (_i,"@14gTotale@21g%s", (const char*) numrom); + set_row (_i,FR("@14gTotale@21g%s"), (const char*) numrom); set_row (_i++,"@86g%s", (const char*) _totale); } } @@ -764,7 +764,7 @@ void BA3800_application::stampa_totali_ditta() //Fai il totale della lettera e stampalo if (_let != ' ') { - set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i,FR("@3gTotale@10g%c@12g)"), _let); set_row (_i++,"@86g%s", (const char*) _totale); } } @@ -775,7 +775,7 @@ void BA3800_application::stampa_totali_ditta() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE ATTIVO"); + set_row (_i,FR("@0gTOTALE ATTIVO")); set_row (_i++,"@86g%s", (const char*) _totale); _totale_attivita_gia_stampato = TRUE; } @@ -784,7 +784,7 @@ void BA3800_application::stampa_totali_ditta() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE PASSIVO"); + set_row (_i,FR("@0gTOTALE PASSIVO")); set_row (_i++,"@86g%s", (const char*) _totale); _totale_passivita_gia_stampato = TRUE; } @@ -793,7 +793,7 @@ void BA3800_application::stampa_totali_ditta() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE CONTI D' ORDINE ATTIVI"); + set_row (_i, FR("@0gTOTALE CONTI D' ORDINE ATTIVI")); set_row (_i++,"@86g%s", (const char*) _totale); gia_stampato_conto_ord = TRUE; } @@ -802,14 +802,14 @@ void BA3800_application::stampa_totali_ditta() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE CONTI D' ORDINE PASSIVI"); + set_row (_i, FR("@0gTOTALE CONTI D' ORDINE PASSIVI")); set_row (_i++,"@86g%s", (const char*) _totale); _i++; gia_stampato_conto_ord = TRUE; if (!_attivo_o_passivo) { - set_row (_i++,"@0gSALDO CONTI D' ORDINE"); - set_row (_i,"@0gSBILANCIO"); + set_row (_i++,FR("@0gSALDO CONTI D' ORDINE")); + set_row (_i,FR("@0gSBILANCIO")); set_row (_i++,"@86g%s", (const char*) _totale); _sbilancio_ordine = TRUE; _sbilancio_patr_gia_stampato = TRUE; @@ -831,7 +831,7 @@ void BA3800_application::stampa_totali_ditta() //Fai il totale del numero arabo e stampalo if (_num != 0) { - set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i,FR("@18gTotale@25g%2d@27g)"), _num); set_row (_i++,"@86g%s", (const char*) _totale); } } @@ -842,7 +842,7 @@ void BA3800_application::stampa_totali_ditta() TString numrom = itor(numeror); if (numrom != "") { - set_row (_i,"@14gTotale@21g%s", (const char*) numrom); + set_row (_i, FR("@14gTotale@21g%s"), (const char*) numrom); set_row (_i++,"@86g%s", (const char*) _totale); } } @@ -853,13 +853,13 @@ void BA3800_application::stampa_totali_ditta() { if (_sez_stamp == '9' && _let_stamp != 'E') { - set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i,FR("@3gTotale@10g%c@12g)"), _let); set_row (_i++,"@86g%s", (const char*) _totale); } else if (_sez_stamp != '9') { - set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i,FR("@3gTotale@10g%c@12g)"), _let); set_row (_i++,"@86g%s", (const char*) _totale); } } @@ -872,7 +872,7 @@ void BA3800_application::stampa_totali_ditta() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE ATTIVO"); + set_row (_i,FR("@0gTOTALE ATTIVO")); set_row (_i++,"@86g%s", (const char*) _totale); } @@ -881,7 +881,7 @@ void BA3800_application::stampa_totali_ditta() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE PASSIVO"); + set_row (_i,FR("@0gTOTALE PASSIVO")); set_row (_i++,"@86g%s", (const char*) _totale); } @@ -893,8 +893,8 @@ void BA3800_application::stampa_totali_ditta() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gSALDO STATO PATRIMONIALE"); - set_row (_i,"@0gSBILANCIO (ATTIVO - PASSIVO)"); + set_row (_i++, FR("@0gSALDO STATO PATRIMONIALE")); + set_row (_i, FR("@0gSBILANCIO (ATTIVO - PASSIVO)")); set_row (_i++,"@86g%s", (const char*) _totale); _sbilancio_patr_gia_stampato = TRUE; } @@ -903,7 +903,7 @@ void BA3800_application::stampa_totali_ditta() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE CONTI D' ORDINE ATTIVI"); + set_row (_i, FR("@0gTOTALE CONTI D' ORDINE ATTIVI")); set_row (_i++,"@86g%s", (const char*) _totale); } @@ -911,14 +911,14 @@ void BA3800_application::stampa_totali_ditta() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE CONTI D' ORDINE PASSIVI"); + set_row (_i,FR("@0gTOTALE CONTI D' ORDINE PASSIVI")); set_row (_i++,"@86g%s", (const char*) _totale); _i++; if (!_sbilancio_ordine) { set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gSALDO CONTI D' ORDINE"); - set_row (_i,"@0gSBILANCIO"); + set_row (_i++, FR("@0gSALDO CONTI D' ORDINE")); + set_row (_i, FR("@0gSBILANCIO")); set_row (_i++,"@86g%s", (const char*) _totale); _sbilancio_ordine = TRUE; } @@ -931,15 +931,15 @@ void BA3800_application::stampa_totali_ditta() if (!_sbilancio_patr_gia_stampato) { set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gSALDO STATO PATRIMONIALE"); - set_row (_i,"@0gSBILANCIO (ATTIVO - PASSIVO)"); + set_row (_i++, FR("@0gSALDO STATO PATRIMONIALE")); + set_row (_i, FR("@0gSBILANCIO (ATTIVO - PASSIVO)")); set_row (_i++,"@86g%s", (const char*) _totale); } if (!_sbilancio_ordine) { set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gSALDO CONTI D' ORDINE"); - set_row (_i,"@0gSBILANCIO"); + set_row (_i++, FR("@0gSALDO CONTI D' ORDINE")); + set_row (_i, FR("@0gSBILANCIO")); set_row (_i++,"@86g%s", (const char*) _totale); } } @@ -947,7 +947,7 @@ void BA3800_application::stampa_totali_ditta() { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gTOTALE CONTI D' ORDINE"); + set_row (_i, FR("@0gTOTALE CONTI D' ORDINE")); set_row (_i++,"@86g%s", (const char*) _totale); } if (_sez_stamp == '9') @@ -956,19 +956,19 @@ void BA3800_application::stampa_totali_ditta() { if ((_let_stamp == 'A' || _let_stamp == 'B') && _diffprod_fatto)//Solo se esiste una delle due lettere { - set_row (_i++,"@4gDifferenza tra valore e costi della produzione@86g%s", (const char*) _totale); + set_row (_i++,FR("@4gDifferenza tra valore e costi della produzione@86g%s"), (const char*) _totale); _diffprod_fatto = FALSE; } if (_risimp_fatto) { - set_row (_i,"@4gRisultato prima delle imposte"); + set_row (_i, FR("@4gRisultato prima delle imposte")); set_row (_i++,"@86g%s", (const char*) _totale); } } char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i,"@0gRISULTATO CONTO ECONOMICO"); + set_row (_i,FR("@0gRISULTATO CONTO ECONOMICO")); set_row (_i++,"@86g%s", (const char*) _totale); } _cont_gcs = 0; @@ -988,7 +988,7 @@ print_action BA3800_application::postprocess_page(int file, int counter) { reset_print(); _i = 1; - setta_righe_studio("CONTO ECONOMICO"); + setta_righe_studio(TR("CONTO ECONOMICO")); _reset_righe_stampa = FALSE; } } @@ -1011,14 +1011,14 @@ print_action BA3800_application::postprocess_page(int file, int counter) { reset_print(); _i = 1; - setta_righe_ditta("CONTI D' ORDINE"); + setta_righe_ditta(TR("CONTI D' ORDINE")); _reset_righe_stampa = FALSE; } if (_sez_da_stamp == '9') { reset_print(); _i = 1; - setta_righe_ditta("CONTO ECONOMICO"); + setta_righe_ditta(TR("CONTO ECONOMICO")); _reset_righe_stampa = FALSE; } } @@ -1198,7 +1198,7 @@ void BA3800_application::set_page(int file, int counter) { if ((_sez_da_stamp=='1')||((_sez_da_stamp=='2')&&(_statopatr_no_stamp))) { - setta_righe_studio ("STATO PATRIMONIALE"); + setta_righe_studio(TR("STATO PATRIMONIALE")); _statopatr_no_stamp = FALSE; } if (_sez_da_stamp == '2') @@ -1218,7 +1218,7 @@ void BA3800_application::set_page(int file, int counter) { if ((_sez_da_stamp=='1')||((_sez_da_stamp=='2')&&(_statopatr_no_stamp))) { - setta_righe_ditta ("STATO PATRIMONIALE"); + setta_righe_ditta (TR("STATO PATRIMONIALE")); _statopatr_no_stamp = FALSE; } if (_sez_da_stamp == '2') @@ -1269,7 +1269,7 @@ void BA3800_application::setta_righe_studio(const char * titolo) { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gATTIVO"); + set_row (_i++, FR("@0gATTIVO")); set_row (_i++,"@0g%c", app); } else @@ -1277,7 +1277,7 @@ void BA3800_application::setta_righe_studio(const char * titolo) { char app = ' '; set_row(_i++,"@0g%c", app); - set_row (_i++,"@0gPASSIVO"); + set_row (_i++, FR("@0gPASSIVO")); set_row(_i++,"@0g%c", app); } @@ -1431,7 +1431,7 @@ void BA3800_application::setta_righe_ditta(const char* titolo) { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gCONTI D' ORDINE ATTIVI"); + set_row (_i++,FR("@0gCONTI D' ORDINE ATTIVI")); set_row (_i++,"@0g%c", app); stampa_classe = FALSE; } @@ -1440,7 +1440,7 @@ void BA3800_application::setta_righe_ditta(const char* titolo) { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gATTIVO"); + set_row (_i++,FR("@0gATTIVO")); set_row (_i++,"@0g%c", app); } @@ -1448,7 +1448,7 @@ void BA3800_application::setta_righe_ditta(const char* titolo) { char app = ' '; set_row(_i++,"@0g%c", app); - set_row (_i++,"@0gCONTI D' ORDINE PASSIVI"); + set_row (_i++, FR("@0gCONTI D' ORDINE PASSIVI")); set_row(_i++,"@0g%c", app); stampa_classe = FALSE; } @@ -1457,7 +1457,7 @@ void BA3800_application::setta_righe_ditta(const char* titolo) { char app = ' '; set_row(_i++,"@0g%c", app); - set_row (_i++,"@0gPASSIVO"); + set_row (_i++, FR("@0gPASSIVO")); set_row(_i++,"@0g%c", app); } @@ -1502,7 +1502,7 @@ void BA3800_application::setta_righe_ditta(const char* titolo) { char app = ' '; set_row (_i++,"@0g%c", app); - set_row (_i++,"@0gCONTI D' ORDINE ATTIVI"); + set_row (_i++,FR("@0gCONTI D' ORDINE ATTIVI")); set_row (_i++,"@0g%c", app); stampa_classe = FALSE; } @@ -1510,7 +1510,7 @@ void BA3800_application::setta_righe_ditta(const char* titolo) { char app = ' '; set_row(_i++,"@0g%c", app); - set_row (_i++,"@0gCONTI D' ORDINE PASSIVI"); + set_row (_i++,FR("@0gCONTI D' ORDINE PASSIVI")); set_row(_i++,"@0g%c", app); stampa_classe = FALSE; } @@ -1660,7 +1660,7 @@ void BA3800_application::intestazione_ditta() cofi = anag.curr().get(ANA_COFI); paiv = anag.curr().get(ANA_PAIV); - set_header (1, "@0gDITTA@6g%-5s", (const char*) codice_ditta); + set_header (1, FR("@0gDITTA@6g%-5s"), (const char*) codice_ditta); set_header (1, "@12g%-45s", (const char*) ragsoc); set_header (1, "@59g%-25s", (const char*) indulc); set_header (1, "@86g%-9s", (const char*) civulc); @@ -1668,16 +1668,16 @@ void BA3800_application::intestazione_ditta() set_header (1, "@103g%-25s", (const char*) com); set_header (1, "@129g%-3s", (const char*) prov); - sep << "Pag. @#"; + sep << FR("Pag. @#"); sep.right_just(132); set_header(2,(const char*) sep); datastampastr = _datastampa.string(); - set_header (2,"@0gPartita iva@12g%-11s", (const char*) paiv); - set_header (2,"@30gCodice fiscale@45g%-16s", (const char*) cofi); - set_header (2,"@105gData@110g%s",(const char*) datastampastr); - set_header (3,"@0gSTAMPA TABELLA IV DIRETTIVA"); + set_header (2,FR("@0gPartita iva@12g%-11s"), (const char*) paiv); + set_header (2,FR("@30gCodice fiscale@45g%-16s"), (const char*) cofi); + set_header (2,FR("@105gData@110g%s"),(const char*) datastampastr); + set_header (3,FR("@0gSTAMPA TABELLA IV DIRETTIVA")); sep.fill('-'); //Stampa 132 - (sep(132)) set_header (4, (const char *) sep); @@ -1690,17 +1690,17 @@ void BA3800_application::intestazione_studio() reset_header(); - sep << "Pag. @#"; + sep << FR("Pag. @#"); sep.right_just(132); set_header(1,(const char*) sep); - set_header (1,"@0gStudio"); + set_header (1,FR("@0gStudio")); //set_header (1,"Nome dello studio"); datastampastr = _datastampa.string(); - set_header (1,"@105gData@110g%s",(const char*) datastampastr); - set_header (2,"@0gSTAMPA TABELLA IV DIRETTIVA"); + set_header (1,FR("@105gData@110g%s"),(const char*) datastampastr); + set_header (2,FR("@0gSTAMPA TABELLA IV DIRETTIVA")); sep.fill('-'); //Stampa 132 - (sep(132)) set_header (3, (const char *) sep); @@ -1832,7 +1832,7 @@ int ba3800 (int argc, char* argv[]) if (argc > 3) { BA3800_application a(*argv[2]); - a.run(argc, argv, "Stampa Tabella IV Direttiva CEE"); + a.run(argc, argv, TR("Stampa Tabella IV Direttiva CEE")); } else error_box("Usage: BA3 -7 {D|S}"); diff --git a/ba/ba3900.cpp b/ba/ba3900.cpp index ee60c2ce0..a76eb6a38 100755 --- a/ba/ba3900.cpp +++ b/ba/ba3900.cpp @@ -58,7 +58,7 @@ bool TIndici_app::ditta_handler(TMask_field& f, KEY key) { m.reset(F_CODREG);m.reset(F_DESCREG); m.disable(F_CODREG); m.disable(F_DESCREG); - return f.error_box("La ditta %5ld non e' abilitata in contabilita'", ditta); + return f.error_box(FR("La ditta %5ld non e' abilitata in contabilita'"), ditta); } } return TRUE; @@ -72,13 +72,13 @@ void TIndici_app::init_query_mode(TMask& m) int TIndici_app::read(TMask& m) { int r = TRelation_application::read(m); - long ditta = m.get_long(F_DITTA); + const long ditta = m.get_long(F_DITTA); if (ditta > 0L) if (prefix().exist(ditta)) set_firm(ditta); else { - error_box("Ditta %5ld non abilitata in contabilita'",ditta); + error_box(FR("Ditta %5ld non abilitata in contabilita'"),ditta); //m.reset(F_CODREG);m.reset(F_DESCREG); m.disable(F_CODREG); m.disable(F_DESCREG); } @@ -101,7 +101,7 @@ bool TIndici_app::user_create() if (!found) { - error_box("Abilitare almeno una ditta in contabilita'."); + error_box(TR("Abilitare almeno una ditta in contabilita'.")); return FALSE; } else @@ -165,6 +165,6 @@ bool TIndici_app::get_next_key(TToken_string& key) int ba3900(int argc, char* argv[]) { TIndici_app app; - app.run(argc, argv, "Indici libro unico"); + app.run(argc, argv, TR("Indici libro unico")); return 0; } diff --git a/ba/ba3a00.cpp b/ba/ba3a00.cpp index 72be1b357..cd4a8aefd 100755 --- a/ba/ba3a00.cpp +++ b/ba/ba3a00.cpp @@ -36,14 +36,14 @@ bool Stampa_condizioni_pagamento_application::preprocess_page(int file, int coun const bool ms_cm = rc.get_bool("B0"); _inizio_cal = rc.get("S1"); - if (ms_cm ) _mese_com = "Si"; - else _mese_com = "No"; + if (ms_cm ) _mese_com = TR("Si"); + else _mese_com = TR("No"); - if (_inizio_cal == "F") _inizio_cal = "Data fattura"; + if (_inizio_cal == "F") _inizio_cal = TR("Data fattura"); else - if (_inizio_cal == "M") _inizio_cal = "Fine mese"; + if (_inizio_cal == "M") _inizio_cal = TR("Fine mese"); else - if (_inizio_cal == "I") _inizio_cal = "Da impostare"; + if (_inizio_cal == "I") _inizio_cal = TR("Da impostare"); return TRUE; } @@ -90,10 +90,10 @@ void Stampa_condizioni_pagamento_application::print_header() reset_header (); set_header (soh++, ""); - set_header (soh++, "@bCONDIZIONI DI PAGAMENTO @r@107gData @> Pag. @#"); + set_header (soh++, FR("@bCONDIZIONI DI PAGAMENTO @r@107gData @> Pag. @#")); set_header (soh++, ""); - set_header (soh++, "@47gTipo@53gInizio@66gMese@73gGiorni@89gIntervallo@108gScadenze@118gTipo@123gUlter."); - set_header (soh++, "Cod.@12gDescrizione@47gdoc.@53gcalcolo@66gcomm.@73gsc. fissa@92grate@103gNr. gg. %% @118grata@123gclass."); + set_header (soh++, FR("@47gTipo@53gInizio@66gMese@73gGiorni@89gIntervallo@108gScadenze@118gTipo@123gUlter.")); + set_header (soh++, FR("Cod.@12gDescrizione@47gdoc.@53gcalcolo@66gcomm.@73gsc. fissa@92grate@103gNr. gg. %% @118grata@123gclass.")); set_header(soh,""); set_background(format("W2l{1,3,132,3}l{1,%d,132,%d}", soh, soh)); } @@ -159,6 +159,6 @@ int ba3a00 (int argc, char* argv[]) Stampa_condizioni_pagamento_application a; - a.run(argc, argv, "Stampa condizioni di pagamento"); + a.run(argc, argv, TR("Stampa condizioni di pagamento")); return 0; } diff --git a/ba/ba4200.cpp b/ba/ba4200.cpp index 5512c8d7e..182ca79b4 100755 --- a/ba/ba4200.cpp +++ b/ba/ba4200.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -21,8 +22,6 @@ class TPersone_app : public TRelation_application TString16 _cod_ana; TMask* _msk[2]; TRelation* _rel[2]; - TLocalisamfile* _comuni; - TLocalisamfile* _tabcom; protected: virtual bool user_create() ; @@ -94,31 +93,6 @@ bool TPersone_app::ba4200_handler(TMask& m, KEY k) return FALSE; } -/*bool TPersone_app::fax_handler(TMask_field& f, KEY k) -{ - bool ok = TRUE; - if (k == K_SPACE) - { - TFilename msg; msg.temp(NULL, "txt"); - ofstream msgf(msg); - msgf.close(); - ok = edit_url(msg); - - if (ok) - { - const TPersone_app& app = (const TPersone_app&)main_app(); - const char* tipo = app.tip_ana() == 'F' ? "Fisiche" : "Giuridiche"; - const char* codice = app.cod_ana(); - - TDDE dde; - TString cmd(80); - cmd << "[SetRecipient(" << tipo << ',' << codice << ")]"; - ok = dde.execute("EASYFAX", "FAX", cmd, "bafax"); - } - } - return ok; -} */ - bool TPersone_app::email_handler(TMask_field& f, KEY k) { if (k == K_SPACE) @@ -203,7 +177,7 @@ void TPersone_app::init_modify_mode(TMask& m) HIDDEN bool stato_hnd(TMask_field& f, KEY key) { if (f.get().empty()) - f.mask().set(FLD_AF1_STATONASC_TABSTE_S0, "Italiana"); + f.mask().set(FLD_AF1_STATONASC_TABSTE_S0, TR("Italiana")); return TRUE; } @@ -318,51 +292,40 @@ bool gest_uff_imp(TMask_field& f, KEY key) if (cod_com.empty()) return TRUE; - TLocalisamfile comuni(LF_COMUNI); - - comuni.setkey(1) ; - comuni.zero() ; - comuni.put(N_COM, cod_com ); - if (comuni.read() == NOERR) + TString16 cod("|"); cod<< cod_com; + + const TRectype & comune = cache().get(LF_COMUNI, cod); + + msk.set(F_IMP_DENCOM, comune.get("DENCOM")); + msk.set(F_IMP_PROVCOM, comune.get("PROVCOM")); + msk.set(F_UFFUUE, comune.get("CODUUE1"),TRUE); + msk.check_field(F_UFFUUE); + + TString80 s(comune.get(N_IMPDIR1)) ; + if (s.empty()) s = comune.get(N_IMPDIR2) ; + if (s.empty()) s = comune.get(N_IMPDIR3) ; + if (msk.get(F_UFFIIDD).empty() || msk.is_running()) + msk.set(F_UFFIIDD, s, TRUE); + s = comune.get(N_IVA1); + if (s.empty()) s = comune.get(N_IVA2) ; + if (s.empty()) s = comune.get(N_IVA3) ; + if (msk.get(F_UFFIVA).empty() || msk.is_running()) + msk.set(F_UFFIVA, s, TRUE); + msk.set(F_UFFREG, comune.get("UFFREG"), TRUE); + if (msk.get_bool(F_TITCF)) { - msk.set(F_IMP_DENCOM, comuni.get("DENCOM")); - msk.set(F_IMP_PROVCOM, comuni.get("PROVCOM")); - msk.set(F_UFFUUE, comuni.get("CODUUE1"),TRUE); - msk.check_field(F_UFFUUE); + if (msk.get(F_UFFCONC).empty() || msk.is_running()) + msk.set(F_UFFCONC, comune.get("UFFCONC")); + msk.set(F_CONFIS, msk.get(giuridica ? FLD_AG1_COFI : FLD_AF1_COFI)); + } + const bool fisica = ! giuridica; + if (fisica && (msk.get(F_CODREG96).empty() || msk.is_running())) + msk.set(F_CODREG96, comune.get("CODREG"), TRUE); + msk.set(F_UFFCONC_P, comune.get("UFFCONC"), TRUE); + msk.set(F_UFFSERV, comune.get("UFFCSERV"), TRUE); - TString s(comuni.get(N_IMPDIR1)) ; - if (s.empty()) s = comuni.get(N_IMPDIR2) ; - if (s.empty()) s = comuni.get(N_IMPDIR3) ; - if (msk.get(F_UFFIIDD).empty() || msk.is_running()) - { - msk.set(F_UFFIIDD, s) ; msk.field(F_UFFIIDD).on_key(K_TAB); - } - s = comuni.get(N_IVA1); - if (s.empty()) s = comuni.get(N_IVA2) ; - if (s.empty()) s = comuni.get(N_IVA3) ; - if (msk.get(F_UFFIVA).empty() || msk.is_running()) - { - msk.set(F_UFFIVA, s) ; msk.field(F_UFFIVA).on_key(K_TAB); - } - msk.set(F_UFFREG, comuni.get("UFFREG")); msk.field(F_UFFREG).on_key(K_TAB); - if (msk.get_bool(F_TITCF)) - { - if (msk.get(F_UFFCONC).empty() || msk.is_running()) - msk.set(F_UFFCONC, comuni.get("UFFCONC")); - msk.set(F_CONFIS, msk.get(giuridica ? FLD_AG1_COFI : FLD_AF1_COFI)); - } - const bool fisica = ! giuridica; - if (fisica && (msk.get(F_CODREG96).empty() || msk.is_running())) - { - msk.set(F_CODREG96, comuni.get("CODREG")); - msk.field(F_CODREG96).on_key(K_TAB); - } - msk.set(F_UFFCONC_P, comuni.get("UFFCONC")); msk.field(F_UFFCONC_P).on_key(K_TAB); - msk.set(F_UFFSERV, comuni.get("UFFCSERV")); msk.field(F_UFFSERV).on_key(K_TAB); - - msk.set(F_CODCONTR_EP, comuni.get("UFFESPROV").mid(1, 2)); - msk.set(F_CODCONTR_EC, comuni.get("UFFESCOM")); - } + msk.set(F_CODCONTR_EP, comune.get("UFFESPROV").mid(1, 2)); + msk.set(F_CODCONTR_EC, comune.get("UFFESCOM")); return TRUE; } @@ -382,16 +345,11 @@ bool tit_cf(TMask_field& f, KEY key) if (cod_com.not_empty()) { - TLocalisamfile comuni(LF_COMUNI); + TString16 key("|"); key << cod_com; + const TRectype & comune = cache().get(LF_COMUNI, key); - comuni.setkey(1) ; - comuni.zero() ; - comuni.put(N_COM, cod_com ); - if (comuni.read() == NOERR) - { if (msk.get(F_UFFCONC).empty() || msk.is_running()) - msk.set(F_UFFCONC, comuni.get("UFFCONC")); - } + msk.set(F_UFFCONC, comune.get("UFFCONC")); } msk.set(F_CONFIS, msk.get(giuridica ? FLD_AG1_COFI : FLD_AF1_COFI)); } @@ -416,12 +374,10 @@ bool uff_conc(TMask_field& f, KEY key) if (cod_com.not_empty()) { - TLocalisamfile comuni(LF_COMUNI); + TString16 key("|"); key << cod_com; + const TRectype & comune = cache().get(LF_COMUNI, key); - comuni.setkey(1) ; - comuni.zero() ; - comuni.put(N_COM, cod_com ); - app.set_reset_uff_conc(comuni.read() == NOERR && msk.get(F_UFFCONC) == comuni.get("UFFCONC")); + app.set_reset_uff_conc((!comune.empty()) && msk.get(F_UFFCONC) == comune.get("UFFCONC")); } } return TRUE; @@ -445,12 +401,10 @@ bool cod_reg(TMask_field& f, KEY key) if (cod_com.not_empty()) { - TLocalisamfile comuni(LF_COMUNI); + TString16 key("|"); key << cod_com; + const TRectype & comune = cache().get(LF_COMUNI, key); - comuni.setkey(1) ; - comuni.zero() ; - comuni.put(N_COM, cod_com ); - app.set_reset_codreg(comuni.read() == NOERR && msk.get(F_CODREG96) == comuni.get("CODREG")); + app.set_reset_codreg((!comune.empty()) && msk.get(F_CODREG96) == comune.get("CODREG")); } } return TRUE; @@ -475,7 +429,7 @@ bool no_dup_fis(TMask_field& f, KEY key) const TString16 s = anag.get(N_CODANAGR), s1 = app.cod_ana(); if (anag.good() && (t1 != t || s1 != s)) - f.message_box("Codice fiscale gia' utilizzato per il codice %c/%s", + f.message_box(FR("Codice fiscale gia' utilizzato per il codice %c/%s"), t, (const char*)s); } return TRUE ; @@ -501,7 +455,7 @@ bool gest_iva(TMask_field& f, KEY key , short fd_sta ,short fd_iva ) const char t = anag.get_char(N_TIPOA), t1 = app.tip_ana(); const TFixed_string s(anag.get(N_CODANAGR)), s1(app.cod_ana()); if (anag.good() && (t1 != t || s1 != s)) - f.message_box("Partita iva gia' definita per il codice : %c/%s", + f.message_box(FR("Partita iva gia' definita per il codice : %c/%s"), t, (const char*) s); } return TRUE ; @@ -528,7 +482,7 @@ bool no_dup_iva_g(TMask_field& f, KEY key) ok = TRUE; } } - if (!ok) return error_box("Partita IVA obbligatoria!"); + if (!ok) return error_box(TR("Partita IVA obbligatoria!")); } return gest_iva(f , key , FLD_AG1_STATOPAIV ,FLD_AG1_PAIV ) ; @@ -578,7 +532,9 @@ TMask* TPersone_app::get_mask(int mode) bool TPersone_app::user_create() { - _msk[MSKF] = NULL; + open_files(LF_COMUNI, LF_ANAG, LF_ANAGFIS, LF_ANAGGIU, LF_TABCOM, 0) ; + + _msk[MSKF] = NULL; _rel[MSKF] = new TRelation(LF_ANAG); _rel[MSKF]->add(LF_ANAGFIS, "CODANAGR=CODANAGR", 1); @@ -586,8 +542,6 @@ bool TPersone_app::user_create() _rel[MSKG] = new TRelation(LF_ANAG); _rel[MSKG]->add(LF_ANAGGIU, "CODANAGR=CODANAGR", 1); - _comuni = new TLocalisamfile(LF_COMUNI) ; - _tabcom = new TLocalisamfile(LF_TABCOM) ; if (argc() > 3) { @@ -613,9 +567,6 @@ bool TPersone_app::user_destroy() if (_msk[j]) delete _msk[j] ; if (_rel[j]) delete _rel[j] ; } - delete _tabcom; - delete _comuni; - return TRUE; } @@ -688,18 +639,6 @@ int TPersone_app::rewrite(const TMask& m) r.lfile(LF_ANAGFIS).zero("CODREG96"); } manual_save(m); - /* if (ana_fis()) - { - if (m.field(FLD_AF2_INDRF).dirty() || m.field(FLD_AF2_CIVRF).dirty() || - m.field(FLD_AF2_CAPRF).dirty() || m.field(FLD_AF2_COMRF).dirty()) - message_box("Attenzione e' stata variata la residenza fiscale. Controllare le unita' locali"); - } - else - { - if (m.field(FLD_AG1_INDRF).dirty() || m.field(FLD_AG1_CIVRF).dirty() || - m.field(FLD_AG1_CAPRF).dirty() || m.field(FLD_AG1_COMRF).dirty()) - message_box("Attenzione e' stata variata la residenza fiscale. Controllare le unita' locali"); - } */ return r.rewrite(); } diff --git a/ba/ba4300.cpp b/ba/ba4300.cpp index 2599aa11d..53464d983 100755 --- a/ba/ba4300.cpp +++ b/ba/ba4300.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -55,10 +56,6 @@ class TDitte_application : public TRelation_application { TMask* _msk; TRelation *_rel; - TLocalisamfile* _anag; - TLocalisamfile* _unloc; - TLocalisamfile* _attiv; - TLocalisamfile* _tabcom; TString16 _oldattprev; bool _cespiti; @@ -169,35 +166,9 @@ bool ba4300_handler(TMask& m, KEY k) return TRUE; } - TDitte_application::TDitte_application() : _cespiti(FALSE) {} -/*bool TDitte_application::fax_handler(TMask_field& f, KEY k) -{ - bool ok = TRUE; - if (k == K_SPACE) - { - TFilename msg; msg.temp(NULL, "txt"); - ofstream msgf(msg); - msgf.close(); - ok = edit_url(msg); - - if (ok) - { - const TDitte_application& app = (const TDitte_application&)main_app(); - const char* tipo = "Ditte"; - const char* codice = f.mask().get(FLD_GD1_CODDITTA); - - TDDE dde; - TString cmd(80); - cmd << "[SetRecipient(" << tipo << ',' << codice << ")]"; - ok = dde.execute("EASYFAX", "FAX", cmd, "bafax"); - } - } - return ok; -} */ - bool TDitte_application::email_handler(TMask_field& f, KEY k) { if (k == K_SPACE) @@ -211,11 +182,9 @@ bool TDitte_application::email_handler(TMask_field& f, KEY k) bool TDitte_application::user_create() // initvar e arrmask { - _rel = new TRelation(LF_NDITTE); - _anag = new TLocalisamfile(LF_ANAG); - _unloc = new TLocalisamfile(LF_UNLOC); - _attiv = new TLocalisamfile(LF_ATTIV); - _tabcom = new TLocalisamfile(LF_TABCOM); + open_files(LF_NDITTE, LF_ANAG, LF_UNLOC, LF_ATTIV, LF_TABCOM, 0); + _rel = new TRelation(LF_NDITTE); + _cespiti = has_module(CEAUT); _msk = new TMask("ba4300a") ; @@ -230,10 +199,6 @@ bool TDitte_application::user_destroy() // releasev e arrmask { delete _msk; delete _rel; - delete _anag; - delete _unloc; - delete _attiv; - delete _tabcom; return TRUE; } @@ -246,73 +211,76 @@ void TDitte_application::set_att_prev(const TMask& m) TRectype& ditte=_rel->curr(); TString codditta(ditte.get(CODDITTA)) ; + TLocalisamfile attiv(LF_ATTIV); if (_oldattprev.not_empty()) { - _attiv->zero() ; - _attiv->put(CODDITTA, codditta) ; - _attiv->put(CODATT, _oldattprev); - if (_attiv->read(_isequal, _lock) == NOERR) + + attiv.put(CODDITTA, codditta) ; + attiv.put(CODATT, _oldattprev); + if (attiv.read(_isequal, _lock) == NOERR) { - _attiv->put("ATTPREV", bool(FALSE)); - if (_attiv->rewrite() != NOERR) - error_box("Non posso aggiornare l'attivita' prevalente precedente : errore n. %d", _attiv->status()); + attiv.put("ATTPREV", bool(FALSE)); + if (attiv.rewrite() != NOERR) + error_box(FR("Non posso aggiornare l'attivita' prevalente precedente : errore n. %d"), attiv.status()); } } - _attiv->zero() ; - _attiv->put(CODDITTA, codditta) ; - _attiv->put(CODATT, attprev) ; + attiv.zero() ; + attiv.put(CODDITTA, codditta) ; + attiv.put(CODATT, attprev) ; - const bool itwas = _attiv->read(_isequal, _lock) == NOERR; + const bool itwas = attiv.read(_isequal, _lock) == NOERR; if (!itwas) { - _attiv->zero() ; - _attiv->put(CODDITTA, codditta) ; - _attiv->put(CODATT, attprev) ; + attiv.zero() ; + attiv.put(CODDITTA, codditta) ; + attiv.put(CODATT, attprev) ; - TTable tabatt(TABATT); - tabatt.zero(); - tabatt.put(CODTAB, ditte.get(CODATTPREV)) ; - if (tabatt.read() == NOERR) - _attiv->put(DESCR, tabatt.get(S0)) ; + const TRectype& tabatt = cache().get(TABATT, ditte.get(CODATTPREV)); + attiv.put(DESCR, tabatt.get(S0)) ; } - _attiv->put("ATTPREV", bool(TRUE)) ; + attiv.put("ATTPREV", bool(TRUE)) ; if (itwas) { - if (_attiv->rewrite() != NOERR) - error_box("Impossibile aggiornare l'attivita' prevalente : errore n. %d", _attiv->status()); + if (attiv.rewrite() != NOERR) + error_box(FR("Impossibile aggiornare l'attivita' prevalente : errore n. %d"), attiv.status()); } else { - if (_attiv->write() != NOERR) - error_box("Impossibile creare l'attivita' prevalente : errore n. %d", _attiv->status()); + if (attiv.write() != NOERR) + error_box(FR("Impossibile creare l'attivita' prevalente : errore n. %d"), attiv.status()); } } int TDitte_application::write(const TMask& m) { const int err = TRelation_application::write(m); + if (err == NOERR) { set_att_prev(m); - const TRectype& ditte = _rel->curr(); - _anag->zero() ; - _anag->put(TIPOA, ditte.get(TIPOA)); - _anag->put(CODANAGR, ditte.get(CODANAGR)); - _anag->read(); - if (_anag->read() == NOERR) + TLocalisamfile anag(LF_ANAG); + const TRectype& ditte = _rel->curr(); + + anag.zero() ; + anag.put(TIPOA, ditte.get(TIPOA)); + anag.put(CODANAGR, ditte.get(CODANAGR)); +// anag.read(); + if (anag.read() == NOERR) { - _unloc->zero() ; - _unloc->put(CODDITTA, ditte.get(CODDITTA)) ; - _unloc->put(CODULC, 1); - _unloc->put(COMULC, _anag->get(COMRES)); - _unloc->put(INDULC, _anag->get(INDRES)); - _unloc->put(CIVULC, _anag->get(CIVRES)); - _unloc->put(CAPULC, _anag->get(CAPRES)); - _unloc->put(COMCCIAA, _anag->get(COMRES)); - _unloc->put(COMTRIB, _anag->get(COMRES)); - _unloc->write(); + TLocalisamfile unloc(LF_UNLOC); + + unloc.zero() ; + unloc.put(CODDITTA, ditte.get(CODDITTA)) ; + unloc.put(CODULC, 1); + unloc.put(COMULC, anag.get(COMRES)); + unloc.put(INDULC, anag.get(INDRES)); + unloc.put(CIVULC, anag.get(CIVRES)); + unloc.put(CAPULC, anag.get(CAPRES)); + unloc.put(COMCCIAA, anag.get(COMRES)); + unloc.put(COMTRIB, anag.get(COMRES)); + unloc.write(); } } return err; @@ -330,11 +298,12 @@ bool TDitte_application::remove() { // Removes all activities const long firm = _msk->get_long(FLD_GD1_CODDITTA); - _attiv->zero(); - TRecfield att_firm(_attiv->curr(),"CODDITTA"); - att_firm = firm; - for (_attiv->read(_isgteq);_attiv->good() && firm == (long)att_firm; _attiv->next()) - _attiv->remove(); + TLocalisamfile attiv(LF_ATTIV); + TRecfield att_firm(attiv.curr(),"CODDITTA"); + + att_firm = firm; + for (attiv.read(_isgteq); attiv.good() && firm == (long)att_firm; attiv.next()) + attiv.remove(); // Removes firm return TRelation_application::remove(); } @@ -433,6 +402,6 @@ void TDitte_application::init_modify_mode(TMask& m) int ba4300(int argc, char* argv[]) { TDitte_application a ; - a.run(argc, argv, "Anagrafica Ditte"); + a.run(argc, argv, TR("Anagrafica Ditte")); return 0; } diff --git a/ba/ba4400.cpp b/ba/ba4400.cpp index 5550fec31..ae4351702 100755 --- a/ba/ba4400.cpp +++ b/ba/ba4400.cpp @@ -7,8 +7,6 @@ class BA4400_application : public TRelation_application { TMask* _msk; TRelation* _rel; - TLocalisamfile* _anag; - TLocalisamfile* _ditte; bool user_create() ; bool user_destroy() ; @@ -45,9 +43,8 @@ HIDDEN bool clear_cap(TMask_field& f, KEY key) bool BA4400_application::user_create() { - _rel = new TRelation(LF_UNLOC) ; - _anag = new TLocalisamfile(LF_ANAG) ; - _ditte = new TLocalisamfile(LF_NDITTE) ; + open_files(LF_UNLOC, LF_ANAG, LF_NDITTE, 0); + _rel = new TRelation(LF_UNLOC) ; _msk = new TMask("ba4400a") ; _msk->set_handler(FLD_UL1_COMULC, clear_cap); _msk->set_handler(FLD_UL2_COMTRIB, clear_cap); @@ -59,8 +56,6 @@ bool BA4400_application::user_destroy() { delete _msk; delete _rel; - delete _anag; - delete _ditte; return TRUE; } @@ -68,6 +63,6 @@ int ba4400(int argc, char* argv[]) { BA4400_application a; - a.run(argc, argv, "Anagrafica Unita' Locali"); + a.run(argc, argv, TR("Anagrafica Unita' Locali")); return 0; } diff --git a/ba/ba4500.cpp b/ba/ba4500.cpp index 24f891028..288278a1c 100755 --- a/ba/ba4500.cpp +++ b/ba/ba4500.cpp @@ -1,3 +1,4 @@ +#include #include #include "ba4.h" #include "ba4500.h" @@ -6,9 +7,6 @@ class TAttivita_application : public TRelation_application { TMask* _msk; TRelation* _rel; - TLocalisamfile * _anag; - TLocalisamfile * _ditte; - TLocalisamfile * _comuni; bool user_create() ; bool user_destroy() ; @@ -44,18 +42,16 @@ bool TAttivita_application::gest_res(TMask_field& f, KEY key) if (f.to_check(key)) { - TLocalisamfile & anag = *app()._anag; - TLocalisamfile & comuni = *app()._comuni; + TString16 cod(msk.get(LST_AT2_TIPOADS)); + cod << "|" << msk.get(FLD_AT2_CODANGRDS); + + const TRectype & anag = cache().get(LF_ANAG, cod); - anag.setkey(1); - anag.zero(); - anag.put(N_TIPOA, msk.get(LST_AT2_TIPOADS)); - anag.put(N_CODANAGR, msk.get(FLD_AT2_CODANGRDS)); - if (anag.read() != NOERR) + if (anag.empty()) return FALSE; - TArray comarr(2), f1(2), f2(2), f3(2); TString cod_com = anag.get(N_CODCOMRF); + TArray comarr(2), f1(2), f2(2), f3(2); msk.set( FLD_AT2_CODANGRDS_ANAGR_RAGSOC , anag.get(N_RAGSOC) ) ; comarr.add(cod_com); @@ -79,16 +75,16 @@ bool TAttivita_application::gest_res(TMask_field& f, KEY key) cod_com = (TString&) comarr[i]; if ( cod_com.not_empty() ) { - comuni.zero() ; - comuni.put(N_COM, cod_com ); - comuni.setkey(1) ; - if (comuni.read() == NOERR) + cod = "|"; cod << cod_com; + const TRectype & comune = cache().get(LF_COMUNI, cod); + + if (!comune.empty()) { msk.set( FLD_AT2_ANAGR_DEP_IND , (const char*) anag.get((TString&) f1[i]) ) ; msk.set( FLD_AT2_ANAGR_DEP_CIV , (const char*) anag.get((TString&) f2[i]) ) ; msk.set( FLD_AT2_ANAGR_DEP_CAP , (const char*) anag.get((TString&) f3[i]) ) ; - msk.set( FLD_AT2_DEP_ANAGR_COMUNI_DESCR , (const char*) comuni.get(N_DENCOM) ) ; - msk.set( FLD_AT2_DEP_ANAGR_COMUNI_PROV , (const char*) comuni.get(N_PROV) ) ; + msk.set( FLD_AT2_DEP_ANAGR_COMUNI_DESCR , (const char*) comune.get(N_DENCOM) ) ; + msk.set( FLD_AT2_DEP_ANAGR_COMUNI_PROV , (const char*) comune.get(N_PROV) ) ; break; } } @@ -113,10 +109,8 @@ HIDDEN bool clear_cap(TMask_field& f, KEY key) bool TAttivita_application::user_create() { - _rel = new TRelation(LF_ATTIV) ; - _anag = new TLocalisamfile(LF_ANAG) ; - _ditte = new TLocalisamfile(LF_NDITTE) ; - _comuni = new TLocalisamfile(LF_COMUNI) ; + open_files(LF_ATTIV, LF_ANAG, LF_NDITTE, LF_COMUNI, 0) ; + _rel = new TRelation(LF_ATTIV) ; _msk = new TMask("ba4500a") ; _msk->set_handler(FLD_AT2_CODANGRDS, gest_res); _msk->set_handler(FLD_AT2_COMCS, clear_cap); @@ -144,9 +138,6 @@ bool TAttivita_application::user_destroy() { delete _msk; delete _rel; - delete _anag; - delete _ditte; - delete _comuni; return TRUE; } @@ -164,7 +155,7 @@ int TAttivita_application::read(TMask& m) int ba4500(int argc, char* argv[]) { TAttivita_application a; - a.run(argc, argv, "Anagrafica Attivita'"); + a.run(argc, argv, TR("Anagrafica Attivita'")); return 0; } diff --git a/ba/ba4600.cpp b/ba/ba4600.cpp index 67abfb414..5785357e1 100755 --- a/ba/ba4600.cpp +++ b/ba/ba4600.cpp @@ -7,8 +7,6 @@ class TSoci_application : public TRelation_application { TMask* _msk; TRelation* _rel; - TLocalisamfile* _anag; - TLocalisamfile* _ditte; virtual bool user_create() ; virtual bool user_destroy() ; @@ -57,7 +55,7 @@ void TSoci_application::update_ap_socio(const TMask& m) int err = NOERR; const char ap = (m.get(FLD_SC1_ANNO)[0] == 'A') ? 'P' : 'A'; - if (yesno_box("Aggiornare il socio anche per l' anno %s?", ap == 'A' ? "in corso" : "precedente")) + if (yesno_box(FR("Aggiornare il socio anche per l' anno %s?"), ap == 'A' ? TR("in corso") : TR("precedente"))) { _rel->save_status(); m.autosave(*_rel); @@ -68,7 +66,7 @@ void TSoci_application::update_ap_socio(const TMask& m) if (was) err = _rel->rewrite(); else err = _rel->write(); if (err != NOERR) - error_box("Aggiornamento socio anno %s - Errore : %d", ap == 'A' ? "in corso" : "precedente", err); + error_box(FR("Aggiornamento socio anno %s - Errore : %d"), ap == 'A' ? TR("in corso") : TR("precedente"), err); _rel->restore_status(); } } @@ -93,7 +91,7 @@ bool TSoci_application::remove() { const char ap = (curr_mask().get(FLD_SC1_ANNO)[0] == 'A') ? 'P' : 'A'; - if (yesno_box("Cancellare il socio anche per l' anno %s?", ap == 'A' ? "in corso" : "precedente")) + if (yesno_box(FR("Cancellare il socio anche per l' anno %s?"), ap == 'A' ? TR("in corso") : TR("precedente"))) { _rel->save_status(); _rel->lfile().put("ATTPREC", ap); @@ -101,7 +99,7 @@ bool TSoci_application::remove() { const int err = _rel->remove(); if (err != NOERR) - error_box("Cancellazione socio anno %s - Errore : %d", ap == 'A' ? "in corso" : "precedente", err); + error_box(FR("Cancellazione socio anno %s - Errore : %d"), ap == 'A' ? TR("in corso") : TR("precedente"), err); } _rel->restore_status(); } @@ -110,9 +108,8 @@ bool TSoci_application::remove() bool TSoci_application::user_create() { - _rel = new TRelation(LF_SOCI) ; - _anag = new TLocalisamfile(LF_ANAG) ; - _ditte = new TLocalisamfile(LF_NDITTE) ; + open_files(LF_SOCI, LF_ANAG, LF_NDITTE, 0) ; + _rel = new TRelation(LF_SOCI) ; _msk = new TMask("ba4600a") ; set_search_field(FLD_SC1_CODANAGRSOH); return TRUE; @@ -121,8 +118,6 @@ bool TSoci_application::user_create() bool TSoci_application::user_destroy() { delete _msk; - delete _ditte; - delete _anag; delete _rel; return TRUE; } @@ -130,6 +125,6 @@ bool TSoci_application::user_destroy() int ba4600(int argc, char* argv[]) { TSoci_application a; - a.run(argc, argv, "Anagrafica Soci"); + a.run(argc, argv, TR("Anagrafica Soci")); return 0; } diff --git a/ba/baformed.cpp b/ba/baformed.cpp index 34691c77a..681292748 100755 --- a/ba/baformed.cpp +++ b/ba/baformed.cpp @@ -275,8 +275,8 @@ bool TForm_editor::menu(MENU_TAG tag) if (!quit) { TString status; - status << "Profilo: " << _form->name(); - status << " codice: " << _form->code(); + status << TR("Profilo: ") << _form->name(); + status << TR(" codice: ") << _form->code(); xvt_statbar_set(status); edit(sec, pt); xvt_statbar_set(" "); @@ -299,7 +299,7 @@ bool TForm_editor::file_handler(TMask_field& f, KEY k) if (*n > ' ') { const char* d = prefix().description(n); - if (*d == '\0') ok = error_box("Nome di file o tabella errato"); + if (*d == '\0') ok = error_box(TR("Nome di file o tabella errato")); f.mask().set(f.dlg()+1, d); } } @@ -536,32 +536,31 @@ bool TForm_editor::edit(char s, pagetype t) switch(s) { case 'F': - caption << "Piede"; break; + caption << TR("Piede"); break; case 'G': - caption << "Sfondo"; break; + caption << TR("Sfondo"); break; case 'H': - caption << "Testa"; break; + caption << TR("Testa"); break; default: - caption << "Corpo"; break; + caption << TR("Corpo"); break; } switch(t) { case first_page: - caption << " della prima pagina"; break; + caption << TR(" della prima pagina"); break; case even_page: - caption << " delle pagine pari"; break; + caption << TR(" delle pagine pari"); break; case last_page: - caption << " dell'ultima pagina"; break; + caption << TR(" dell'ultima pagina"); break; default: - caption << " standard"; break; + caption << TR(" standard"); break; } dirty = TRUE; if (!_form->exist(s, t)) { - const KEY k = yesnocancel_box("La sezione %s non esiste:\n" - "si desidera generare quella standard?", + const KEY k = yesnocancel_box(FR("La sezione %s non esiste:\nsi desidera generare quella standard?"), (const char*)caption); if (k == K_ESC) dirty = FALSE; @@ -580,7 +579,7 @@ bool TForm_editor::edit(char s, pagetype t) dirty = _form->section(s, t).edit(caption); } - if (dirty && yesno_box("Salvare le modifiche?")) + if (dirty && yesno_box(TR("Salvare le modifiche?"))) { if (_form->code() == "") { @@ -614,7 +613,7 @@ bool TForm_editor::form_config() const const TFilename maskname(cnf.get("EdMask")); if (maskname.empty()) - return warning_box("Nessun parametro da configurare"); + return warning_box(TR("Nessun parametro da configurare")); TMask m(maskname); @@ -669,7 +668,7 @@ bool TForm_editor::ask_profile() cod.format("%05ld",fcode); if (!_extra && (fcode == 0 || fform.left(3) == "BOL")) { - error_box("Non e' possibile modificare i profili standard o i bollettini.") ; + error_box(TR("Non e' possibile modificare i profili standard o i bollettini.")) ; continue; } if (k == K_ENTER) @@ -680,7 +679,7 @@ bool TForm_editor::ask_profile() } else if (k == K_DEL) { - if (fcode != 0 && yesno_box("Confermare la cancellazione del profilo %05ld", fcode)) + if (fcode != 0 && yesno_box(FR("Confermare la cancellazione del profilo %05ld"), fcode)) { TLocalisamfile frm(LF_FORM); frm.zero(); diff --git a/include/controls.cpp b/include/controls.cpp index 1ca732e69..2536f8124 100755 --- a/include/controls.cpp +++ b/include/controls.cpp @@ -446,7 +446,9 @@ WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy, if (dx <= 0) { - width = max_rct.right - left + dx * CHARX; + width = max_rct.right + dx * CHARX; + if (left > 0) + width -= left; #ifndef XVAGA if (!tag && dx == 0 && y > 0) // Aggiusta toolbar top++; diff --git a/include/diction.cpp b/include/diction.cpp index 08b904503..3dba11893 100755 --- a/include/diction.cpp +++ b/include/diction.cpp @@ -73,22 +73,16 @@ const char* TTraduttore::translate(const char* sentence) { if (sentence && *sentence && active()) { - TString str = sentence; str.trim(); - bool has_letters = false; - for (int i = 0; str[i]; i++) + for (int i = 0; sentence[i]; i++) { - if (isalpha(str[i])) + if (isalpha(sentence[i])) { - has_letters = true; + TString* trans = (TString*)objptr(sentence); + if (trans != NULL && trans->not_empty()) + return (const char*) *trans; break; } } - if (has_letters) - { - TString* trans = (TString*)objptr(str); - if (trans != NULL && trans->not_empty()) - sentence = (const char*)*trans; - } } return sentence; } diff --git a/include/diction.h b/include/diction.h index a53e35304..9123fe5b6 100755 --- a/include/diction.h +++ b/include/diction.h @@ -22,7 +22,8 @@ void dictionary_close(); #define TR(str) dictionary_translate_macro(TO_BE_TRANSLATED##str) #define PR(str) dictionary_translate_macro_prompt(TO_BE_TRANSLATED##str) -#define BR(str) dictionary_translate_macro_prompt(TO_BE_TRANSLATED##str, -1) +#define BR(str, len) dictionary_translate_macro_prompt(TO_BE_TRANSLATED##str, len) #define HR(str) dictionary_translate_macro_header(TO_BE_TRANSLATED##str) +#define FR(str) dictionary_translate_macro(TO_BE_TRANSLATED##str) #endif \ No newline at end of file diff --git a/include/fraction.cpp b/include/fraction.cpp new file mode 100755 index 000000000..c4b6fcca3 --- /dev/null +++ b/include/fraction.cpp @@ -0,0 +1,439 @@ +#include +#include +#include +#include +#include + +void fraction::simplify() +{ + __int64 div = mcd(_num, _den); + if (div > 1) + { + _num /= div; + _den /= div; + } + if (_den < 0) + { + _num = -_num; + _den = -_den; + } +} + +void fraction::build_fraction (const char *s) +{ + TString n = get_tmp_string(80); n = s; + + _num = 0; + _den = 1; + if (n.not_empty()) + { + int pdec = n.find(','); + const int psqr = n.find('['), psls = n.find('/'); + int ndec = 0, len_periodo = 0, sign = 1, anti_periodo = 0; + if (pdec < 0) + pdec = n.find('.'); + + if (n.find('-') >= 0) + sign = -1; + if (pdec >= 0) + ndec = n.len() - pdec - 1; + + if (psls > 0) + { + TString80 num(n.left(psls)); + fraction a(num); + num = n.mid(psls + 1); + fraction b(num); + *this = a / b; + return; + } + if (psqr > 0) + { + int end = n.find(']'); + + if (end < psqr) + end = n.len(); + len_periodo = end - psqr - 1; + anti_periodo = psqr -pdec - 1; + } + else + if (ndec > 2) + { + bool found = FALSE; + int j; + + for (const char * pc = (const char *)n + pdec + 1; !found && *pc != NULL;pc++) + { + int max_period = strlen(pc) / 3; + for (j = max_period; !found && j > 0 ; j--) + { + int len, pos; + + for (int c = 0; c < j; c++) + { + const char * pp = pc + c; + len = strlen(pp); + char cmp = *pp; + pos = 0; + while (pos < len) + { + if (pp[pos] != cmp) + if (pos < len - 1 || (pp[pos] - cmp) != 1 || *(pp + 1) < '5') + break; + pos += j; + } + if (pos < len) + break; + } + found = (pos == len) && (c == (len + 1) % j + 1); + } + if (!found) + anti_periodo++; + } + if (found) + { + len_periodo = j + 1; + n.cut(pdec + anti_periodo + len_periodo + 1); + } + } + n.strip(",.-+/[]"); + sscanf(n, "%Ld", &_num); + if (len_periodo > 0) + { + _den = 9; + __int64 sub = _num / 10; + for (int l = len_periodo - 1; l > 0 ; l--) + { + _den = (_den * 10) + 9; + sub /= 10; + } + if (anti_periodo > 0) + for (int p = anti_periodo; p > 0; p--) + _den *= 10; + _num -= sub; + } + else + for (int p = ndec; p > 0; p--) + _den *= 10; + + _num *= sign; + } + simplify(); +} + +fraction::fraction () +{ + _num = 0; + _den = 1; +} + +fraction::fraction(const fraction & b) +{ + _num = b._num; + _den = b._den; +} + +fraction& fraction::operator =(const fraction & b) +{ + _num = b._num; + _den = b._den; + return *this; +} + +fraction& fraction::operator += (const fraction & b) +{ + __int64 m = mcm(_den, b._den); + + _num = _num * ( m / _den) + b._num * ( m / b._den); + _den = m; + simplify(); + return *this; +} + +fraction& fraction::operator -= (const fraction & b) +{ + __int64 m = mcm(_den, b._den); + + _num = _num * ( m / _den) - b._num * ( m / b._den); + _den = m; + simplify(); + return *this; +} + +fraction& fraction::operator *= (const fraction & b) +{ + _num = _num * b._num; + _den = _den * b._den; + simplify(); + return *this; +} + +fraction& fraction::operator /= (const fraction & b) +{ + _num = _num * b._den; + _den = _den * b._num; + simplify(); + return *this; +} + +fraction fraction::operator - () const +{ + fraction b(*this); + + b._num = -b._num; + return b; +} + +// Funzioni comuni dei due real + +TObject* fraction::dup () const +{ + return new fraction(*this); +} + +fraction::operator real () const +{ + real n, d; + n.set_int64(_num); + d.set_int64(_den); + + return n / d; +} + +// @doc EXTERNAL + +// @func real | operator + | Somma due numeri reali +// +// @rdesc Ritorna il valore della somma +fraction operator + ( + const fraction & a, // @parm Primo addendo da sommare + const fraction & b) // @parm Secondo addendo da sommare + + // @syntax operator +(const fraction & a, const fraction & b); + // @syntax operator +(const real & a, const fraction & b); + // @syntax operator +(const fraction & a, const real & b); + +{ + fraction f = a; + f += b; + return f; +} + +// @doc EXTERNAL + +// @func real | operator - | Sottrae due numeri reali +// +// @rdesc Ritorna il valore della sottrazione +fraction operator - ( + const fraction & a, // @parm Primo addendo da sottrarre + const fraction & b) // @parm Secondo addendo da sottrarre + + // @syntax operator -(const fraction & a, const fraction & b); + // @syntax operator -(const real & a, const fraction & b); + // @syntax operator -(const fraction & a, const real & b); +{ + fraction f = a; + f -= b; + return f; +} + +// @doc EXTERNAL + +// @func real | operator * | Moltiplica due numeri reali +// +// @rdesc Ritorna il valore della moltiplicazione +fraction operator *( + const fraction & a, // @parm Prima frazione da moltiplicare + const fraction & b) // @parm Seconda frazione da moltiplicare + + // @syntax operator *(const real &a, const real &b); + // @syntax operator *(double a, const real &b); + // @syntax operator *(const real &a, double b); + +{ + fraction f = a; + f *= b; + return f; +} + +// @doc EXTERNAL + +// @func real | operator / | Divide due numeri reali +// +// @rdesc Ritorna il valore della divisione +fraction operator / ( + const fraction & a, // @parm Prima frazione da dividere + const fraction & b) // @parm Seconda frazione da dividere + + // @syntax operator /(const real &a, const real &b); + // @syntax operator /(double a, const real &b); + // @syntax operator /(const real &a, double b); +{ + fraction f = a; + f /= b; + return f; +} + +// @doc EXTERNAL + +// @func bool | operator | Controlla se un reale e' maggiore di un altro +// +// @rdesc Ritorna i seguenti valori +// +// @flag TRUE | Se

e' maggiore di

+// @flag FALSE | Se

e' non maggiore di

+bool operator > ( + const fraction & a, // @parm Prima frazione da confrontare + const fraction & b) // @parm Seconda frazione da confrontare + + // @syntax operator (const fraction & a, const fraction & b); + // @syntax operator (const real & a, const fraction &b); + // @syntax operator (const fraction &a, const real & b); + +{ + fraction f = a - b; + return f.sign() > 0; +} + +// @doc EXTERNAL + +// @func bool | operator | Controlla se un reale e' minore di un altro +// +// @rdesc Ritorna i seguenti valori +// +// @flag TRUE | Se

e' minore di

+// @flag FALSE | Se

e' non minore di

+bool operator < ( + const fraction & a, // @parm Prima frazione da confrontare + const fraction & b) // @parm Seconda frazione da confrontare + + // @syntax operator (const fraction &a, const fractio &b); + // @syntax operator (const real & a, const fraction &b); + // @syntax operator (const fraction &a, const real & b); + +{ + fraction f = a - b; + return f.sign() < 0; +} + +// @doc EXTERNAL + +// @func bool | operator = | Controlla se un reale e' maggiore o uguale ad +// un altro +// +// @rdesc Ritorna i seguenti valori +// +// @flag TRUE | Se

e' maggiore o uguale a

+// @flag FALSE | Se

e' minore di

+bool operator >= ( + const fraction & a, // @parm Prima frazione da confrontare + const fraction & b) // @parm Seconda frazione da confrontare + + // @syntax operator = (const fraction &a, const fractio &b); + // @syntax operator = (const real & a, const fraction &b); + // @syntax operator = (const fraction &a, const real & b); + +{ + fraction f = a - b; + return f.sign() >= 0; +} + +// @doc EXTERNAL + +// @func bool | operator = | Controlla se un reale e' minore o uguale ad +// un altro +// +// @rdesc Ritorna i seguenti valori +// +// @flag TRUE | Se

e' minore o uguale a

+// @flag FALSE | Se

e' maggiore di

+bool operator <= ( + const fraction & a, // @parm Prima frazione da confrontare + const fraction & b) // @parm Seconda frazione da confrontare + + // @syntax operator = (const fraction &a, const fractio &b); + // @syntax operator = (const real & a, const fraction &b); + // @syntax operator = (const fraction &a, const real & b); +{ + fraction f = a - b; + return f.sign() <= 0; +} + +// @doc EXTERNAL + +// @func bool | operator == | Controlla se un reale e' uguale ad un altro +// +// @rdesc Ritorna i seguenti valori +// +// @flag TRUE | Se

e' uguale a

+// @flag FALSE | Se

non e' uguale a

+bool operator == ( + const fraction & a, // @parm Prima frazione da confrontare + const fraction & b) // @parm Seconda frazione da confrontare + + // @syntax operator == (const fraction &a, const fractio &b); + // @syntax operator == (const real & a, const fraction &b); + // @syntax operator == (const fraction &a, const real & b); +{ + fraction f = a - b; + return f.sign() == 0; +} + +// @doc EXTERNAL + +// @func bool | operator != | Controlla se 2 reali dono diversi +// +// @rdesc Ritorna i seguenti valori +// +// @flag TRUE | Se

e' diverso da

+// @flag FALSE | Se

e' uguale a

+bool operator != ( + const fraction & a, // @parm Prima frazione da confrontare + const fraction & b) // @parm Seconda frazione da confrontare + + // @syntax operator != (const fraction &a, const fractio &b); + // @syntax operator != (const real & a, const fraction &b); + // @syntax operator != (const fraction &a, const real & b); +{ + return ! ::operator ==(a, b); +} + +// @doc EXTERNAL + +// @func Scambia la frazione

con la frazione

+void swap ( + fraction & a, // @parm Prima frazione da scambiare + fraction & b) // @parm Seconda frazione da scambiare + +{ + fraction f = a; + a = b; + b = f; +} + +// @doc EXTERNAL + +// @func Ritorna il numero reale piu' piccolo tra

e

+const fraction& fnc_min ( + const fraction & a, // @parm Prima frazione da confrontare + const fraction & b) // @parm Seconda frazione da confrontare + +// @syntax const real& fnc_min (const fraction & a, const fraction & b) + +{ + return a < b ? a : b; +} + +// @doc EXTERNAL + +// @func Ritorna il numero reale piu' grande tra

e

+const fraction& fnc_max ( + const fraction & a, // @parm Prima frazione da confrontare + const fraction & b) // @parm Seconda frazione da confrontare + +// @syntax const real& fnc_max (const fraction & a, const fraction & b) + +{ + return a > b ? a : b; +} + diff --git a/include/fraction.h b/include/fraction.h new file mode 100755 index 000000000..9211b880e --- /dev/null +++ b/include/fraction.h @@ -0,0 +1,121 @@ +#ifndef __FRACTION_H +#define __FRACTION_H + +#ifndef __STRINGS_H +#include +#endif + +#ifndef __REAL_H +#include +#endif + +#ifndef __IOSTREAM_H +#include +#endif + +// @doc EXTERNAL + +// @class fraction (per GREENLEAF) | Classe per la gestione dei numeri frazionari +// +// @base public | TObject + +class fraction : public TObject + +// @author:(INTERNAL) Guido +{ + // @access:(INTERNAL) Private Member + // @cmember:(INTERNAL) Numero fractione + + __int64 _num; + __int64 _den; + + // @access Protected Member +protected: + // @cmember Duplica il numero frazionario (vedi classe ) + virtual TObject* dup() const; + // @cmember assegna il numero frazionario (vedi classe ) + void simplify(); + void build_fraction(const char * s); + + // @access Public Member +public: + // @cmember Controlla se si tratta di un fractione uguale 0 (TRUE se 0) + bool is_zero() const { return _num == 0;} + // @cmember Ritorna il segno del fractione + int sign() const { return (_num > 0) * (_den > 0);} + // @cmember Trasforma il fractione in intero (operator int era troppo pericoloso) + __int64 integer() const { return _num / _den;} + + // @cmember Assegna una frazione + fraction& operator =(const fraction& b); + // @cmember Aggiunge ad un frazione il valore passato + fraction& operator +=(const fraction& b); + // @cmember Sottrae ad un frazione il valore passato + fraction& operator -=(const fraction& b); + // @cmember Moltiplica un fractione per il valore passato (passato per indirizzo) + fraction& operator *=(const fraction& b); + // @cmember Divide un fractione per il valore passato (passato per indirizzo) + fraction& operator /=(const fraction& b); + // @cmember Ritorna la negazione di un frazione (TRUE se 0, altrimenti FALSE) + bool operator !() const { return is_zero(); } + // @cmember Ritorna il risultato della differenza tra due frazioni + fraction operator -() const; + + // @cmember converte la frazione in reale + operator real() const; + + // @cmember Costruttore + fraction(); + // @cmember Costruttore + fraction(const real & b) { build_fraction(b.string()); } + // @cmember Costruttore + fraction(const fraction& b) ; + // @cmember Costruttore + fraction(const char* s) { build_fraction(s); } + // @cmember Distruttore + virtual ~fraction() + {} +}; + +/////////////////////////////////////////////////////////// +// Math operators +/////////////////////////////////////////////////////////// + +fraction operator +(const fraction& a, const fraction& b) ; +inline fraction operator +(const real& a, const fraction& b) { return ::operator +((fraction)a, b);} +inline fraction operator +(const fraction& a, const real& b) { return ::operator +(b, a);} +fraction operator -(const fraction& a, const fraction& b) ; +inline fraction operator -(const real& a, const fraction& b) { return ::operator -((fraction)a, b);} +inline fraction operator -(const fraction& a, const real& b) { return ::operator -(a, (fraction)b);} +fraction operator *(const fraction& a, const fraction& b) ; +inline fraction operator *(const real& a, const fraction& b) { return ::operator *((fraction)a, b);} +inline fraction operator *(const fraction& a, const real& b) { return ::operator *(b, a);} +fraction operator /(const fraction& a, const fraction& b) ; +inline fraction operator /(const real& a, const fraction& b) { return ::operator /((fraction)a, b);} +inline fraction operator /(const fraction& a, const real& b) { return ::operator /(a, (fraction)b);} + +bool operator <(const fraction& a, const fraction& b) ; +inline bool operator <(const real& a, const fraction& b) { return ::operator < (a, (real)b);} +inline bool operator <(const fraction& a, const real& b) { return ::operator <((real) a, b);} +bool operator >(const fraction& a, const fraction& b) ; +inline bool operator >(const real& a, const fraction& b) { return ::operator > (a, (real)b);}; +inline bool operator >(const fraction& a, const real& b) { return ::operator >((real) a, b);} +bool operator <=(const fraction& a, const fraction& b) ; +inline bool operator <=(const real& a, const fraction& b) { return ::operator <= (a, (real)b);} +inline bool operator <=(const fraction& a, const real& b) { return operator <=((real) a, b);} +bool operator >=(const fraction& a, const fraction& b) ; +inline bool operator >=(const real& a, const fraction& b) { return operator >=(a, (real) b);} +inline bool operator >=(const fraction& a, const real& b) { return operator >=((real) a, b);} +bool operator ==(const fraction& a, const fraction& b) ; +inline bool operator ==(const real& a, const fraction& b) { return operator ==(a, (real) b);} +inline bool operator ==(const fraction& a, const real& b) { return operator ==((real) a, b);} +bool operator !=(const fraction& a, const fraction& b) ; +inline bool operator !=(const real& a, const fraction& b) { return operator !=(a, (real) b);} +inline bool operator !=(const fraction& a, const real& b) { return operator !=((real) a, b);} + +real operator %(const real& a, const real& b) ; +void swap(fraction& a, fraction& b) ; +const fraction& fnc_min(const fraction& a, const fraction& b); +const fraction& fnc_max(const fraction& a, const fraction& b); + +#endif \ No newline at end of file diff --git a/include/maskfld.cpp b/include/maskfld.cpp index dc13b2307..b46884ac1 100755 --- a/include/maskfld.cpp +++ b/include/maskfld.cpp @@ -1060,23 +1060,23 @@ void TButton_field::create(WINDOW parent) { case DLG_OK: if (_ctl_data._prompt.empty() || _ctl_data._prompt == "Conferma") - _ctl_data._prompt = BR("~Conferma"); + _ctl_data._prompt = BR("~Conferma", _ctl_data._width); _exit_key = K_ENTER; - if (_ctl_data._bmp_up == 0 && _ctl_data._prompt == BR("~Conferma")) + if (_ctl_data._bmp_up == 0 && _ctl_data._prompt == BR("~Conferma", _ctl_data._width)) _ctl_data._bmp_up = BMP_OK; break; case DLG_CANCEL: if (_ctl_data._prompt.empty()) - _ctl_data._prompt = BR("Annulla"); + _ctl_data._prompt = BR("Annulla", _ctl_data._width); _virtual_key = _exit_key = K_ESC; - if (_ctl_data._bmp_up == 0 && _ctl_data._prompt == BR("Annulla")) + if (_ctl_data._bmp_up == 0 && _ctl_data._prompt == BR("Annulla", _ctl_data._width)) _ctl_data._bmp_up = BMP_CANCEL; break; case DLG_DELREC: if (_ctl_data._prompt.empty() || _ctl_data._prompt == "Elimina") - _ctl_data._prompt = BR("~Elimina"); + _ctl_data._prompt = BR("~Elimina", _ctl_data._width); _exit_key = K_DEL; - if (_ctl_data._bmp_up == 0 && _ctl_data._prompt == BR("~Elimina")) + if (_ctl_data._bmp_up == 0 && _ctl_data._prompt == BR("~Elimina", _ctl_data._width)) { _ctl_data._bmp_up = BMP_DELREC; _ctl_data._bmp_dn = BMP_DELRECDN; @@ -1084,17 +1084,17 @@ void TButton_field::create(WINDOW parent) break; case DLG_PRINT: if (_ctl_data._prompt.empty() || _ctl_data._prompt == "Stampa") - _ctl_data._prompt = BR("~Stampa"); + _ctl_data._prompt = BR("~Stampa", _ctl_data._width); _exit_key = K_ENTER; - if (_ctl_data._bmp_up <= 0 && _ctl_data._prompt == BR("~Stampa")) + if (_ctl_data._bmp_up <= 0 && _ctl_data._prompt == BR("~Stampa", _ctl_data._width)) _ctl_data._bmp_up = BMP_PRINT; break; case DLG_QUIT: if (_ctl_data._prompt.empty()) - _ctl_data._prompt = BR("Fine"); + _ctl_data._prompt = BR("Fine", _ctl_data._width); _virtual_key = K_F4; _exit_key = K_QUIT; - if (_ctl_data._bmp_up <= 0 && _ctl_data._prompt == BR("Fine")) + if (_ctl_data._bmp_up <= 0 && _ctl_data._prompt == BR("Fine", _ctl_data._width)) { _ctl_data._bmp_up = BMP_QUIT; _ctl_data._bmp_dn = BMP_QUITDN; diff --git a/include/netsock.cpp b/include/netsock.cpp index 09f43327d..e0b69d4a6 100755 --- a/include/netsock.cpp +++ b/include/netsock.cpp @@ -753,15 +753,16 @@ bool TSocketClient::HttpGetDir(CONNID id, const char* remote, TString_array& lis if (ok) { ifstream s(local); - TString riga; + TString riga(256); while (!s.eof()) { s.getline(riga.get_buffer(), riga.size()); + const int img = riga.find(" 0) + if (img >= 0 && href > img) { const int start = riga.find('"', href) + 1; - if (start > href) + if (start > href && isalnum(riga[start + 1])) { const int stop = riga.find('"', start); if (stop > start) diff --git a/include/printer.cpp b/include/printer.cpp index 494c6bba9..d73e5f651 100755 --- a/include/printer.cpp +++ b/include/printer.cpp @@ -906,10 +906,7 @@ HIDDEN bool set_windows_print_device (TMask_field& f, KEY key) TWait_cursor hourglass; TPrinter& pr = printer(); - - TToken_string pn; os_get_printer_names(pn); - const TString pdev (pn.get(atoi (f.get()))); // Nome stampante corrente - + const TString& pdev = f.get(); // Nome stampante corrente os_set_default_printer(pdev); if (m.is_running()) { @@ -920,17 +917,16 @@ HIDDEN bool set_windows_print_device (TMask_field& f, KEY key) const int MAX_FAMILIES = 128; char* family[MAX_FAMILIES]; const int num_families = (int)xvt_fmap_get_families(pr.get_printrcd(), family, MAX_FAMILIES); - TToken_string pn1(256), pn2(256); + TToken_string fn(256); for (int i = 0; i < num_families; i++) { - pn1.add(family[i]); - pn2.add(family[i]); + fn.add(family[i]); xvt_mem_free(family[i]); } TList_field& lst = (TList_field&)m.field(MSK_FONT); - lst.replace_items(pn1, pn2); + lst.replace_items(fn, fn); m.set(MSK_FONT, printer().fontname(), TRUE); } diff --git a/include/progind.cpp b/include/progind.cpp index cf81a6f90..7f9239210 100755 --- a/include/progind.cpp +++ b/include/progind.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -11,8 +12,6 @@ extern "C" } #endif -const char* const TITLE_TEXT = "Attesa"; - word TIndwin::measure_text(TToken_string& s, word& maxlen) const { word lines = 0; @@ -42,13 +41,11 @@ TIndwin::TIndwin(long max, const char* txt, bool cancel, bool bar, int div) ver += bar ? 1 : 0; ver += cancel ? 2 : 0; - set_win(create_interface(TASK_WIN, -1, -1, hor, ver, TITLE_TEXT, this, FALSE)); + set_win(create_interface(TASK_WIN, -1, -1, hor, ver, TR("Attesa"), this, FALSE)); _text = new TMultiline_control(win(), DLG_NULL, 1, 0, hor-2, lines+1, 512, "CD", ""); _text->set_read_only(); -// testo.replace('\n', '\r'); qui - set_text(testo); if (bar) @@ -58,7 +55,7 @@ TIndwin::TIndwin(long max, const char* txt, bool cancel, bool bar, int div) } if (cancel) - _cancel = new TPushbutton_control(win(), DLG_CANCEL, -11, -1, 12, 2, "", "Annulla", BMP_CANCEL); + _cancel = new TPushbutton_control(win(), DLG_CANCEL, -11, -1, 12, 2, "", TR("Annulla"), BMP_CANCEL); open_modal(); do_events(); } @@ -101,7 +98,7 @@ TIndwin::~TIndwin() bool TIndwin::can_be_closed() const { const bool ok = (_flags & IND_FINISHED) || (_flags & IND_CANCELLED); - if (!ok) error_box("Attendere la fine dell'operazione prima di chiudere l'applicazione"); + if (!ok) error_box(TR("Attendere la fine dell'operazione prima di chiudere l'applicazione")); return ok; } @@ -122,7 +119,7 @@ RCT* TIndwin::get_bar_rct(RCT& r) const r.left += CHARX; r.right -= CHARX; r.top = (int)_bar; - r.bottom = r.top + 2*CHARY; + r.bottom = r.top + 3*CHARY/2; return &r; } @@ -146,6 +143,20 @@ void TIndwin::update_bar() if (CAMPI_SCAVATI) { + COLOR cBar = COLOR_DKBLUE, cText = COLOR_WHITE; + XVT_COLOR_COMPONENT* xcc = (XVT_COLOR_COMPONENT*)xvt_vobj_get_attr(NULL_WIN, ATTR_APP_CTL_COLORS); + if (xcc) + { + for (int c = 0; xcc[c].type != XVT_COLOR_NULL; c++) + { + if (xcc[c].type == XVT_COLOR_CAPTIONLT) + cBar = xcc[c].color; + if (xcc[c].type == XVT_COLOR_CAPTIONTEXT) + cText = xcc[c].color; + } + xvt_mem_free((char*)xcc); + } + // Rettangolo scavato xi_draw_3d_rect(w, &r, TRUE, 2, MASK_LIGHT_COLOR, BTN_BACK_COLOR, MASK_DARK_COLOR); @@ -153,13 +164,14 @@ void TIndwin::update_bar() b.top += 2; b.bottom -= 2; b.right = b.left + int((b.right-b.left)*prc); - set_brush(COLOR_BLUE, PAT_SOLID); + set_brush(cBar, PAT_SOLID); + xvt_dwin_draw_rect(w, &b); set_pen(BTN_BACK_COLOR); const int nStep = b.bottom-b.top; for (int x = b.left+nStep; x < b.right; x += nStep) { - for (int i = 0; i < 2; i++) + for (int i = 0; i < 1; i++) // for (int i = 0; i < 2; i++) { PNT pt = { b.top, x+i }; xvt_dwin_draw_set_pos(w, pt); @@ -167,7 +179,7 @@ void TIndwin::update_bar() xvt_dwin_draw_line(w, pt); } } - set_color(COLOR_WHITE, COLOR_DKBLUE); + set_color(cText, cBar); } else { @@ -337,4 +349,3 @@ void timerind_destroy() delete __indwin__p; __indwin__p = NULL; } - diff --git a/include/real.cpp b/include/real.cpp index 9ca6fdae1..a3d6a1e94 100755 --- a/include/real.cpp +++ b/include/real.cpp @@ -30,6 +30,11 @@ real::real (const real& b) : _dec(b._dec) real::real (long double a) : _dec(a) { } +void::real set_int64(__int64 b) +{ + _dec = b; +} + bool real::is_real (const char *s) { if (s && *s) @@ -392,6 +397,13 @@ real::real (double a) } +void real::set_int64(__int64 b) +{ + dzero (ptr ()); + trail(); + memcpy(ptr()->ls.lsl, &b, sizeof(b)); +} + void real::trail( ) { deltrz (ptr (), ptr () ); // Delete Trailing zeroes diff --git a/include/real.h b/include/real.h index 88c45a3db..5ec5711ce 100755 --- a/include/real.h +++ b/include/real.h @@ -89,6 +89,8 @@ public: real& operator = (const real& a); // @cmember Assegna un reale real& operator =(long double a); + // @cmember Assegna un __int64 ad un reale + void set_int64(__int64 b); // @cmember Aggiunge ad un reale il valore passato (passato per indirizzo) real& operator +=(long double a); // @cmember Sottrae ad un reale il valore passato (passato per indirizzo) @@ -224,6 +226,8 @@ public: real& floor(int prec = 0); // @cmember Assegna un reale real& operator =(double a); + // @cmember Assegna un __int64 ad un reale + void set_int64(__int64 b); // @cmember Assegna un reale (passato per indirizzo) real& operator =(const real& b); // @cmember Aggiunge ad un reale il valore passato (passato per indirizzo) diff --git a/include/resource.ini b/include/resource.ini new file mode 100755 index 000000000..b547b62de --- /dev/null +++ b/include/resource.ini @@ -0,0 +1,166 @@ +[Cursors] +8001=resize.cur +8002=hand.cur +8003=vresize.cur + +[Icons] +9012=campo.ico +10108=combo.ico +10109=search.ico +10110=checkon.ico +10111=checkoff.ico + +[Images] +101=ok.bmp +102=cancel.bmp +103=saverec.bmp +104=delrec.bmp +105=newrec.bmp +108=fax.bmp +109=search.bmp +114=quit.bmp +115=select.bmp +116=edit.bmp +117=link.bmp +118=print.bmp +119=recalc.bmp +120=elabora.bmp +123=stoprec.bmp +126=findrec.bmp +127=module1.bmp +128=module2.bmp +129=module3.bmp +130=module4.bmp +134=module.bmp +135=ole.bmp +139=email.bmp +153=saverecd.bmp +154=delrecdn.bmp +155=newrecdn.bmp +164=quitdn.bmp +165=setprint.bmp +167=dir.bmp +168=dirdn.bmp +169=file.bmp +170=stop.bmp +171=filechk.bmp + +10101=ok.gif +10102=cancel.gif +10103=saverec.gif +10104=delrec.gif +10105=newrec.gif +10114=quit.gif +10139=email.gif +10153=saverecd.gif +10154=delrecdn.gif +10155=newrecdn.gif +10164=quitdn.gif + +30001=euro01.bmp +30002=euro02.bmp +30003=euro03.bmp +30004=euro04.bmp +30005=euro05.bmp +30006=euro06.bmp +30007=euro07.bmp +30008=euro08.bmp +30009=euro09.bmp +30010=euro10.bmp +30011=euro11.bmp +30012=euro12.bmp +30013=euro13.bmp +30014=euro14.bmp +30015=euro15.bmp +30016=euro16.bmp +30017=euro17.bmp + +[Menu_7000] +Item_00 = 10001,&Visualizzazione +Item_00_00 = 7003,Interrompi\tESC +Item_00_01 = 7004,Colle&ga...\tCtrl+G,D +Item_00_02 = 7005,&Esporta...\tCtrl+E +Item_00_03 = 7006,&Stampa... \tCtrl+S,D +Item_00_04 = -1,Separator +Item_00_05 = 7007,Mostra &righelli,C +Item_00_06 = 7008,Mostra &bottoni,C +Item_00_07 = 7009,Ri&disegna +Item_00_08 = -1,Separator +Item_00_09 = 7010,Chiudi\tESC+ESC +Item_01 = 10002,&Modifica +Item_01_00 = 7011,&Copia,D +Item_01_01 = 7012,&Annulla,D +Item_01_02 = -1,Separator +Item_01_03 = 7013,Cerca...\tF7, +Item_01_04 = 7014,Cerca il prossimo\tF8,D + +[Menu_BA0-0] +Item_00 = 32050,&Opzioni +Item_00_00 = 30002,&Font e Colori +Item_00_01 = 30003,&Editors +Item_00_02 = -1,Separator +Item_00_03 = 30004,Cambio &studio +Item_01 = 32350,&Preferiti +Item_01_00 = 30005,&Aggiungi +Item_01_01 = 30006,&Organizza + +[Menu_BA2-0] +Item_00=5100,&Dati +Item_00_00=30011,&Relazione +Item_00_01=30012,&Parametri +Item_00_02=30013,Caratteri &fincatura +Item_00_03=30014,&Cambia profilo +Item_00_04=30015,Imposta formato &numeri +Item_00_05=30016,Imposta formato &date +Item_01=5200,&Testa +Item_01_00=30021,&Normale +Item_01_01=30022,&Pari +Item_01_02=30023,&Prima +Item_01_03=30024,&Ultima +Item_02=5300,&Corpo +Item_02_00=30031,&Normale +Item_02_01=30032,&Pari +Item_02_02=30033,&Primo +Item_02_03=30034,&Ultimo +Item_03=5400,&Piede +Item_03_00=30041,&Normale +Item_03_01=30042,&Pari +Item_03_02=30043,&Primo +Item_03_03=30044,&Ultimo +Item_04=5500,&Sfondo +Item_04_00=30051,&Normale +Item_04_01=30052,&Pari +Item_04_02=30053,&Primo +Item_04_03=30054,&Ultimo + +[Menu_BA2-5] +Item_00=5100,&Maschera +Item_00_00=30011,&Nuova +Item_00_01=30012,&Apri +Item_00_02=30013,&Salva +Item_00_03=30014,Salva &con nome +Item_01=5200,&Modifica +Item_01_00=30021,&Copia-Incolla +Item_01_01=30022,Ca&ncella\tCANC +Item_01_02=30023,S&posta in...\tF2 +Item_02=5300,&Aggiungi +Item_02_00=30031,&Button +Item_02_01=30032,B&ooleano +Item_02_02=30033,Currenc&y +Item_02_03=30034,&Date +Item_02_04=30035,Gru&ppo +Item_02_05=30036,&Lista +Item_02_06=30037,&Memo +Item_02_07=30038,&Numero +Item_02_08=30039,P&ulsantiera +Item_02_09=30310,Ta&bella +Item_02_10=30311,S&tringa +Item_02_11=30312,Te&sto +Item_02_12=30313,&Zoom +Item_03=5200,&Visualizza +Item_03_00=30041,&Controlli presenti\tF3 +Item_03_01=30042,&Maschera di sheet\tF4 +Item_03_02=30043,Co&ntrolli-maschera sheet\tF5 +Item_04=5200,&Test +Item_04_00=30051,&Compilazione +Item_04_01=30052,&Esecuzione diff --git a/include/utility.cpp b/include/utility.cpp index 54a73dde7..c68ae359f 100755 --- a/include/utility.cpp +++ b/include/utility.cpp @@ -467,3 +467,34 @@ const char * decode( return __tmp_string; } +__int64 mcd(__int64 a, __int64 b) + +{ + if (a < 0) + a = -a; + if (b < 0) + b = -b; + + __int64 r; + + while (b > 0) + { + r = a % b; +// if (r == 0) +// break; + a = b; + b = r; + } + return a; +} + +__int64 mcm(__int64 a, __int64 b) + +{ + if (a < 0) + a = -a; + if (b < 0) + b = -b; + + return ((a * b) / mcd(a, b)); +} diff --git a/include/utility.h b/include/utility.h index 315739e51..607bcac67 100755 --- a/include/utility.h +++ b/include/utility.h @@ -41,6 +41,9 @@ const char* unesc(const char* str); // Trasforma i caratteri '\n' nella sequenza #define ODD(x) (x & 1) #define EVEN(x) !(x & 1) +__int64 mcd(__int64 a, __int64 b); +__int64 mcm(__int64 a, __int64 b); + #ifdef __UTILITY_CPP char __tmp_string[1024]; #else diff --git a/include/validate.cpp b/include/validate.cpp index e09840cbe..cf54e0c52 100755 --- a/include/validate.cpp +++ b/include/validate.cpp @@ -28,7 +28,7 @@ HIDDEN bool _expr_val(TMask_field& f, KEY) const char* s = e.varname(i); if (s[0] != '#') { - TString80 err; err << "Non trovo la variabile " << s << " in " << e; + TString err; err << "Non esiste la variabile " << s << " in " << e; return f.error_box((const char*)err); } s++; diff --git a/m770/777100.cpp b/m770/777100.cpp index f4eb4c53e..4eb6f7ada 100755 --- a/m770/777100.cpp +++ b/m770/777100.cpp @@ -1049,18 +1049,22 @@ const TString& TTrasferimento770::read_codfis_dic(const TRectype& rec) key = rec.get(BSE_CODDITTA); const TRectype& rec_nditte = _cache770.get(LF_NDITTE, key); - if (rec_nditte.empty()) - return error_box("Non esiste la ditta %s", (const char*)key); - + if (rec_nditte.empty()) + { + error_box("Non esiste la ditta %s", (const char*)key); + return EMPTY_STRING; + } const char tipoa = rec_nditte.get_char(NDT_TIPOA); const long codan = rec_nditte.get_long(NDT_CODANAGR); key.cut(0); key << tipoa << '|' << rec_nditte.get(NDT_CODANAGR); const TRectype& rec_anagr = _cache770.get(LF_ANAG, key); - if (rec_anagr.empty()) - return error_box("Non esiste la persona %s", (const char*)key); - + if (rec_anagr.empty()) + { + error_box("Non esiste la persona %s", (const char*)key); + return EMPTY_STRING; + } _cod_fis_dic = rec_anagr.get(ANA_COFI); // Codice fiscale del dichiarante return _cod_fis_dic; diff --git a/server/authoriz.cpp b/server/authoriz.cpp new file mode 100755 index 000000000..6e458fe1c --- /dev/null +++ b/server/authoriz.cpp @@ -0,0 +1,816 @@ +#include "BaseServ.h" + +#include "Dongle.h" + +/////////////////////////////////////////////////////////// +// TUserInfo +/////////////////////////////////////////////////////////// + +class TUserInfo : public wxObject +{ +public: + wxString m_strName; + wxString m_strHost; + wxDateTime m_time; + size_t m_nPrograms; + + TUserInfo(const wxChar* user, const wxChar* host); +}; + +TUserInfo::TUserInfo(const wxChar* user, const wxChar* host) + : m_strName(user), m_strHost(host), + m_time(wxDateTime::Now()), m_nPrograms(0) +{ +} + +class TUserTable : public wxObject +{ + wxHashTable m_Hash; + +public: + TUserInfo* AddConnection(wxSocketBase& sock, const wxChar* user); + TUserInfo* Find(wxSocketBase& sock, const wxChar* user); + void RemoveConnection(wxSocketBase& sock, const wxChar* user); + void Kill(const wxChar* user); + + size_t GetCount() const { return m_Hash.GetCount(); } + void BeginFind() { m_Hash.BeginFind(); } + TUserInfo* Next() { wxNode* n = m_Hash.Next(); return n ? (TUserInfo*)n->GetData() : NULL; } + + TUserTable(size_t size = 13); +}; + +TUserInfo* TUserTable::AddConnection(wxSocketBase& sock, const wxChar* user) +{ + TUserInfo* ui = Find(sock, user); + if (ui == NULL) + { + wxIPV4address peer; sock.GetPeer(peer); + const wxString host = peer.Hostname(); + ui = new TUserInfo(user, host); + m_Hash.Put(wxString::Format("%s@%s", user, host), ui); + } + ui->m_nPrograms++; + + return ui; +} + +TUserInfo* TUserTable::Find(wxSocketBase& sock, const wxChar* user) +{ + wxIPV4address peer; sock.GetPeer(peer); + const wxString host = peer.Hostname(); + + if (user && *user) + return (TUserInfo*)m_Hash.Get(wxString::Format("%s@%s", user, host)); + + BeginFind(); + for (TUserInfo* ui = Next(); ui; ui = Next()) + { + if (ui->m_strHost == host) + return ui; + } + + return NULL; +} + +void TUserTable::RemoveConnection(wxSocketBase& sock, const wxChar* user) +{ + TUserInfo* ui = Find(sock, user); + if (ui) + { + ui->m_nPrograms--; + if (ui->m_nPrograms <= 0) + m_Hash.Delete(wxString::Format("%s@%s", ui->m_strName, ui->m_strHost)); + } +} + +void TUserTable::Kill(const wxChar* strUser) +{ + BeginFind(); + for (TUserInfo* ui = Next(); ui; ui = Next()) + { + if (ui->m_strName == strUser) + { + m_Hash.Delete(wxString::Format("%s@%s", ui->m_strName, ui->m_strHost)); + break; + } + } +} + +TUserTable::TUserTable(size_t size) : m_Hash(wxKEY_STRING, size) +{ + m_Hash.DeleteContents(true); +} + +/////////////////////////////////////////////////////////// +// TAuthorizationServer +/////////////////////////////////////////////////////////// + +class TAuthorizationServer : public TBaseServerApp +{ +private: + TDongle m_Dongle; + unsigned long m_Modules[3]; + unsigned int m_nModules; + wxString m_strLastPassword; + + TUserTable m_Users; + +protected: + virtual const wxChar* GetAppName() const; + virtual void ProcessCommand(wxString cmd, wxSocketBase& outs); + + void AddNumber(TXmlItem& tr, int n) const; + wxString DescribeModule(int m) const; + + void InitModules(); + wxString Garble(unsigned short n, const wxDateTime& date) const; + +public: + bool IsMagicName(wxString& strFilename) const; + + void GenerateIndex(wxString& strFilename); + void GenerateUsers(wxString& strFilename); + void GenerateModules(wxString& strFilename); + void GenerateFile(wxString& strFile); + void ProcessFormCommand(wxString cmd, wxSocketBase& outs); + + void ProcessActivation(int nModuble, bool act, wxSocketBase& outs); + void ReturnInt(wxSocketBase& outs, unsigned int i); + void ReturnBool(wxSocketBase&, bool b); + + unsigned int DecodePassword(const wxChar* strPassword); + void ProcessUserLogin(wxString cmd, wxSocketBase& sock); + bool ProcessUserLogout(wxString cmd, wxSocketBase& sock); + + virtual bool Initialization(); + virtual bool Deinitialization(); +}; + +void TAuthorizationServer::InitModules() +{ + m_nModules = 0; + memset(m_Modules, 0, sizeof(m_Modules)); + m_Modules[0] = 2*sizeof(long); + if (m_Dongle.Ok()) + { + for (int i = 0; i < 48; i++) + { + if (m_Dongle.Active(i+1)) + { + const size_t index = i / 32; + const unsigned long mask = 1 << (i & 31); + m_Modules[index+1] |= mask; + m_nModules++; + } + } + } +} + +wxString TAuthorizationServer::Garble(unsigned short n, const wxDateTime& date) const +{ + const long val = date2julian(date); + + unsigned short data[4]; + data[0] = m_Dongle.Number(); + data[1] = n; + data[2] = unsigned short(val >> 16); + data[3] = unsigned short(val & 0xFFFF); + m_Dongle.garble(data); + return wxString::Format("%04X%04X", data[0], data[1]); +} + +// Implementare almeno queste due funzioni pure virtuali + +const wxChar* TAuthorizationServer::GetAppName() const +{ + return "Authorization"; +} + +bool TAuthorizationServer::IsMagicName(wxString& strFilename) const +{ + wxString strName; + wxSplitPath(strFilename, NULL, &strName, NULL); + strName.MakeLower(); + const int q = strName.Find('?'); + if (q > 0) + strName.Truncate(q); + + if (strName == "index" || strName == "users" || strName == "modules") + { + strFilename = strName; + return true; + } else + if (strName == "log") + { + strFilename = GetLogFileName(); + } else + if (strName == "activate" || strName == "deactivate" || + strName == "year" || strName == "maxusers" || strName == "kill") + { + return true; + } + + return false; +} + +wxString TAuthorizationServer::DescribeModule(int m) const +{ + wxFileInputStream aut("../campo.aut"); + wxString line; + for (int nModule = 0; !aut.Eof(); nModule++) + { + aut >> line; + if (nModule == m) + return line.Mid(3); + } + return line; // Should never happen! +} + + +void TAuthorizationServer::AddNumber(TXmlItem& tr, int n) const +{ + TXmlItem& td = tr.AddChild("td"); + td.SetAttr("align", "right"); + td << wxString::Format("%d", n); +} + +void TAuthorizationServer::GenerateIndex(wxString& strFilename) +{ + TXmlItem html; + TXmlItem& body = CreatePageBody(html); + + TXmlItem& title = body.AddChild("h1").AddChild("center"); + if (m_Dongle.Ok()) + { + const bool hard = m_Dongle.hardware() == _dongle_hardlock; + TXmlItem& img = title.AddChild("img"); + img.SetAttr("src", hard ? "hardlock.gif" : "eutron.gif"); + title << (hard ? "Hardlock EYE" : "Eutron Smartkey"); + } + else + { + title << "No Dongle Connected!"; + } + body.AddChild("br"); + + TXmlItem& table = body.AddChild("center").AddChild("table"); + table.SetAttr("border", "1"); + table.SetAttr("width", "70%"); + + TXmlItem& tr0 = body.AddChild("tr"); + tr0.AddChild("td") << "Serial Number"; + AddNumber(tr0, m_Dongle.Number()); + + TXmlItem& tr1 = body.AddChild("tr"); + TXmlItem& ay = tr1.AddChild("td").AddChild("a"); + ay.SetAttr("href", "year") << "Assistance Year"; + AddNumber(tr1, m_Dongle.YearAssist()); + + TXmlItem& tr2 = body.AddChild("tr"); + TXmlItem& mu = tr2.AddChild("td").AddChild("a"); + mu.SetAttr("href", "maxusers") << "Maximum Users"; + AddNumber(tr2, m_Dongle.MaxUsers()); + + TXmlItem& tr3 = body.AddChild("tr"); + TXmlItem& au = tr3.AddChild("td").AddChild("a"); + au.SetAttr("href", "Users"); au << "Active Users"; + AddNumber(tr3, m_Users.GetCount()); + + TXmlItem& tr4 = body.AddChild("tr"); + TXmlItem& am = tr4.AddChild("td").AddChild("a"); + am.SetAttr("href", "Modules"); am << "Active Modules"; + AddNumber(tr4, m_nModules); + + TXmlItem& tr5 = body.AddChild("tr"); + TXmlItem& al = tr5.AddChild("td").AddChild("a"); + al.SetAttr("href", "Log"); al << "Log File"; + + TXmlItem& tr6 = body.AddChild("tr"); + TXmlItem& as = tr6.AddChild("td").AddChild("a"); + as.SetAttr("href", "stop.cgi"); as << "Stop the Server"; + + strFilename = GetTempFilename(); + html.Save(strFilename); +} + +void TAuthorizationServer::GenerateModules(wxString& strFilename) +{ + TXmlItem html; + TXmlItem& body = CreatePageBody(html, "Modules"); + TXmlItem& table = body.AddChild("table"); + table.SetAttr("border", "1"); table.SetAttr("width", "100%"); + + TXmlItem& th = body.AddChild("thead"); + th.AddChild("th").SetAttr("width", "7%") << "N."; + th.AddChild("th").SetAttr("width", "8%") << "Module"; + th.AddChild("th").SetAttr("width", "70%") << "Description"; + th.AddChild("th").SetAttr("width", "15%") << "De/Activate"; + + wxFileInputStream aut("../campo.aut"); + wxString line; + for (int nModule = 0; !aut.Eof(); nModule++) + { + aut >> line; + + const wxString strCode = line.Left(2); + const wxString strDesc = line.Mid(3); + if (nModule > 0 && strCode != "xx" && !strDesc.IsEmpty()) + { + TXmlItem& tr = body.AddChild("tr"); + AddNumber(tr, nModule); + tr.AddChild("td").SetAttr("align", "center") << strCode; + tr.AddChild("td") << strDesc; + if (nModule > 0) + { + const wxString prompt = m_Dongle.Active(nModule) ? "Deactivate" : "Activate"; + const wxString href = wxString::Format("%s?%d", prompt, nModule); + TXmlItem& bu = AddLinkButton(tr.AddChild("td"), prompt, href); + bu.SetAttr("width", "100%"); + bu.SetAttr("title", wxString::Format("Click to %s Module %d", prompt, nModule)); + } + } + } + + strFilename = GetTempFilename(); + html.Save(strFilename); +} + +void TAuthorizationServer::GenerateUsers(wxString& strFilename) +{ + TXmlItem html; + TXmlItem& body = CreatePageBody(html, "Users"); + + TXmlItem& table = body.AddChild("table"); + table.SetAttr("border", "1"); table.SetAttr("width", "100%"); + + TXmlItem& th = table.AddChild("thead"); + th.AddChild("th").SetAttr("width", "15%") << "N."; + th.AddChild("th").SetAttr("width", "10%") << "User"; + th.AddChild("th").SetAttr("width", "15%") << "Host"; + th.AddChild("th").SetAttr("width", "15%") << "Programs"; + th.AddChild("th").SetAttr("width", "15%") << "Time"; + th.AddChild("th").SetAttr("width", "15%") << "Date"; + th.AddChild("th").SetAttr("width", "15%") << "Kill"; + + m_Users.BeginFind(); + int nUser = 0; + for (TUserInfo* ui = m_Users.Next(); ui; ui = m_Users.Next()) + { + TXmlItem& tr = table.AddChild("tr"); + tr.AddChild("td").SetAttr("align", "right") << wxString::Format("%d", ++nUser); + tr.AddChild("td").AddChild("b") << ui->m_strName; + tr.AddChild("td") << ui->m_strHost; + tr.AddChild("td").SetAttr("align", "right") << wxString::Format("%u", ui->m_nPrograms); + tr.AddChild("td").SetAttr("align", "center") << ui->m_time.Format("%H:%M:%S"); + tr.AddChild("td").SetAttr("align", "center") << ui->m_time.Format("%d-%m-%Y"); + + wxString href = wxString::Format("kill.cgi?%s", ui->m_strName); + AddLinkButton(tr.AddChild("td"), "Kill", href).SetAttr("width", "100%"); + } + + body.AddChild("br"); + body.AddChild("center"); + AddLinkButton(body, "Return to main page", "/"); + + strFilename = GetTempFilename(); + html.Save(strFilename); +} + +void TAuthorizationServer::GenerateFile(wxString& strFilename) +{ + const int q = strFilename.Find('?'); + wxString strArgs; + if (q > 0) + { + strArgs = strFilename.Mid(q+1); + strFilename.Truncate(q); + } + + wxString strName; + wxSplitPath(strFilename, NULL, &strName, NULL); + strName.MakeLower(); + + if (strName == "index") + { + GenerateIndex(strFilename); + } else + if (strName == "modules") + { + GenerateModules(strFilename); + } else + if (strName == "users") + { + GenerateUsers(strFilename); + } else + if (strName == "log") + { + strFilename = GetLogFileName(); + } else + if (strName == "activate") + { + const int nModule = atoi(strArgs); + + TXmlItem html; + TXmlItem& body = CreatePageBody(html); + TXmlItem& form = body.AddChild("form"); + form.SetAttr("action", "activate"); form.SetAttr("method", "post"); + + TXmlItem& table = form.AddChild("center").AddChild("table"); + table.SetAttr("width", "70%").SetAttr("border", "1"); + table.AddChild("caption").AddChild("h2") << "Module Activation"; + + TXmlItem& tr0 = table.AddChild("tr"); + tr0.AddChild("td") << "Module to be activated"; + tr0.AddChild("td") << DescribeModule(nModule); + + TXmlItem& tr1 = table.AddChild("tr"); + tr1.AddChild("td") << "Activation date (dd-mm-yyyy)"; + TXmlItem& date = tr1.AddChild("td").AddChild("input"); + date.SetAttr("type", "string"); date.SetAttr("name", "date"); + date.SetAttr("size", "10"); date.SetAttr("maxlength", "10"); + date.SetAttr("value", Date2String(wxDateTime::Now())); + + TXmlItem& tr2 = table.AddChild("tr"); + tr2.AddChild("td") << "Activation code"; + + TXmlItem& key = tr2.AddChild("td").AddChild("input"); + key.SetAttr("type", "string"); key.SetAttr("name", "key"); + key.SetAttr("size", "8"); key.SetAttr("maxlength", "8"); + + TXmlItem& tr3 = table.AddChild("tr"); + tr3.AddChild("td").AddChild("a").SetAttr("href", "/") << "Return to main page"; + TXmlItem& submit = tr3.AddChild("td").AddChild("input"); + submit.SetAttr("type", "submit"); + submit.SetAttr("value", "Confirm Activation"); + + strFilename = GetTempFilename(); + html.Save(strFilename); + } else + if (strName == "deactivate") + { + const int nModule = atoi(strArgs); + TXmlItem html; + TXmlItem& body = CreatePageBody(html).AddChild("center"); + body.AddChild("h1") << "WARNING!"; + body.AddChild("br"); + body.AddChild("h3") << "You are about to deactivate the following module:"; + body.AddChild("br"); + body.AddChild("h2") << DescribeModule(nModule); + body.AddChild("br"); + TXmlItem& form = body.AddChild("form"); + form.SetAttr("action", "deactivate"); form.SetAttr("method", "post"); + TXmlItem& module = form.AddChild("input"); + module.SetAttr("type", "hidden"); + module.SetAttr("name", "module"); + module.SetAttr("value", wxString::Format("%d", nModule)); + + TXmlItem& submit = form.AddChild("input"); + submit.SetAttr("type", "submit"); + submit.SetAttr("value", "Confirm Deactivation"); + + body.AddChild("br"); body.AddChild("br"); + AddLinkButton(body, "Return to modules list", "Modules"); + + strFilename = GetTempFilename(); + html.Save(strFilename); + } else + if (strName == "year") + { + const int nModule = atoi(strArgs); + TXmlItem html; + TXmlItem& body = CreatePageBody(html); + TXmlItem& form = body.AddChild("form"); + form.SetAttr("action", "year"); form.SetAttr("method", "post"); + + TXmlItem& table = form.AddChild("center").AddChild("table"); + table.SetAttr("width", "70%").SetAttr("border", "1"); + table.AddChild("caption").AddChild("h2") << "Year of Assistance"; + + TXmlItem& tr0 = table.AddChild("tr"); + tr0.AddChild("td") << "Assistance year to be activated"; + + TXmlItem& year = tr0.AddChild("td").AddChild("input"); + year.SetAttr("type", "string"); year.SetAttr("name", "year"); + year.SetAttr("size", "4"); year.SetAttr("maxlength", "4"); + year.SetAttr("value", wxString::Format("%d", m_Dongle.YearAssist()+1)); + + TXmlItem& tr1 = table.AddChild("tr"); + tr1.AddChild("td") << "Activation date (dd-mm-yyyy)"; + TXmlItem& date = tr1.AddChild("td").AddChild("input"); + date.SetAttr("type", "string"); date.SetAttr("name", "date"); + date.SetAttr("size", "10"); date.SetAttr("maxlength", "10"); + date.SetAttr("value", Date2String(wxDateTime::Now())); + + TXmlItem& tr2 = table.AddChild("tr"); + tr2.AddChild("td") << "Activation code"; + + TXmlItem& key = tr2.AddChild("td").AddChild("input"); + key.SetAttr("type", "string"); key.SetAttr("name", "key"); + key.SetAttr("size", "8"); key.SetAttr("maxlength", "8"); + + TXmlItem& tr3 = table.AddChild("tr"); + tr3.AddChild("td").AddChild("a").SetAttr("href", "/") << "Return to main page"; + TXmlItem& submit = tr3.AddChild("td").AddChild("input"); + submit.SetAttr("type", "submit"); + submit.SetAttr("value", "Confirm Activation"); + + strFilename = GetTempFilename(); + html.Save(strFilename); + } else + if (strName == "maxusers") + { + const int nModule = atoi(strArgs); + TXmlItem html; + TXmlItem& body = CreatePageBody(html); + TXmlItem& form = body.AddChild("form"); + form.SetAttr("action", "maxusers"); form.SetAttr("method", "post"); + + TXmlItem& table = form.AddChild("center").AddChild("table"); + table.SetAttr("width", "70%").SetAttr("border", "1"); + table.AddChild("caption").AddChild("h2") << "Maximum Users"; + + TXmlItem& tr0 = table.AddChild("tr"); + tr0.AddChild("td") << "Number of users"; + + TXmlItem& year = tr0.AddChild("td").AddChild("input"); + year.SetAttr("type", "string"); year.SetAttr("name", "users"); + year.SetAttr("size", "4"); year.SetAttr("maxlength", "4"); + year.SetAttr("value", wxString::Format("%d", m_Dongle.MaxUsers())); + + TXmlItem& tr1 = table.AddChild("tr"); + tr1.AddChild("td") << "Activation date (dd-mm-yyyy)"; + TXmlItem& date = tr1.AddChild("td").AddChild("input"); + date.SetAttr("type", "string"); date.SetAttr("name", "date"); + date.SetAttr("size", "10"); date.SetAttr("maxlength", "10"); + date.SetAttr("value", Date2String(wxDateTime::Now())); + + TXmlItem& tr2 = table.AddChild("tr"); + tr2.AddChild("td") << "Activation code"; + + TXmlItem& key = tr2.AddChild("td").AddChild("input"); + key.SetAttr("type", "string"); key.SetAttr("name", "key"); + key.SetAttr("size", "8"); key.SetAttr("maxlength", "8"); + form.AddChild("br"); form.AddChild("br"); + + TXmlItem& tr3 = table.AddChild("tr"); + tr3.AddChild("td").AddChild("a").SetAttr("href", "index") << "Return to main page"; + TXmlItem& submit = tr3.AddChild("td").AddChild("input"); + submit.SetAttr("type", "submit"); + submit.SetAttr("value", "Confirm Activation"); + + strFilename = GetTempFilename(); + html.Save(strFilename); + } else + if (strName == "kill") + { + m_Users.Kill(strArgs); + GenerateUsers(strFilename); + } +} + +void TAuthorizationServer::ProcessActivation(int nModule, bool act, wxSocketBase& outs) +{ + if (nModule > 0) + { + if (act) + m_Dongle.Activate(nModule); + else + m_Dongle.Deactivate(nModule); + m_Dongle.Burn(); + InitModules(); + } + wxString strFileName = "Modules"; + GenerateFile(strFileName); + SendFile(strFileName, outs); +} + +void TAuthorizationServer::ProcessFormCommand(wxString cmd, wxSocketBase& outs) +{ + const int stop = cmd.Find(" HTTP"); + wxString strFileName = cmd.Mid(5, stop-5).Trim(); + + wxString strName, args; + wxSplitPath(strFileName, NULL, &strName, NULL); + strName.MakeLower(); + + const int pos = cmd.Find("\r\n\r\n"); + if (pos > 0) + args = cmd.Mid(pos+4); + + THashTable hashArgs(13); + ParseArguments(args, hashArgs); + + if (strName == "activate") + { + const int nModule = hashArgs.GetInt("module"); + const wxDateTime date = hashArgs.GetDate("date"); + const wxString key = hashArgs.Get("key"); + const wxString gar = Garble(nModule, date); + if (key.IsSameAs(gar, false)) + ProcessActivation(nModule, true, outs); + else + MessageBox("ERROR!", "You supplied the wrong activation code", outs); + } else + if (strName == "deactivate") + { + const int nModule = atoi(hashArgs.Get("module")); + ProcessActivation(nModule, false, outs); + } else + if (strName == "year") + { + const int year = hashArgs.GetInt("year"); + const wxDateTime date = hashArgs.GetDate("date"); + const wxString key = hashArgs.Get("key"); + const wxString gar = Garble(year, date); + if (key.IsSameAs(gar, false)) + { + m_Dongle.set_year_assist(year); + m_Dongle.Burn(); + wxString strFileName = "index"; + GenerateFile(strFileName); + SendFile(strFileName, outs); + } + else + MessageBox("ERROR!", "You supplied the wrong activation code", outs); + } else + if (strName == "maxusers") + { + const int users = atoi(hashArgs.Get("users")); + const wxDateTime date = hashArgs.GetDate("date"); + const wxString key = hashArgs.Get("key"); + const wxString gar = Garble(users, date); + if (key.IsSameAs(gar, false)) + { + m_Dongle.set_max_users(users); + m_Dongle.Burn(); + wxString strFileName = "index"; + GenerateFile(strFileName); + SendFile(strFileName, outs); + } + else + MessageBox("ERROR!", "You supplied the wrong activation code", outs); + } +} + +unsigned int TAuthorizationServer::DecodePassword(const wxChar* strPassword) +{ + const unsigned int BASE = 19; + unsigned int num = 0; + size_t len = 0; + for (const wxChar* c = strPassword; *c; c++) + { + num *= BASE; + if (*c >= '0' && *c <= '9') + { + num += *c - '0'; + } + else + { + if (*c >= 'A' && *c <= 'Z') + { + num += *c - 'A' + 10; + } + else + { + if (*c >= 'a' && *c <= 'z') + num += *c - 'a' + 10; + } + } + len++; + } + // Per essereva valido deve essere divisibile per 883 + if (len >= 5 && (num%883) == 0 && m_strLastPassword != strPassword) + { + num /= 2; + while (num % 883 != 0) + num++; + m_strLastPassword = strPassword; + } + else + num = 0; + return num; +} + +void TAuthorizationServer::ProcessUserLogin(wxString cmd, wxSocketBase& sock) +{ + wxChar strUser[16]; + wxChar strPassword[16]; + wxChar strProgram[16]; + wxString strHost; + cmd.Replace(",", " "); cmd.Replace(")", " "); + sscanf(cmd, "UserLogin(%s %s %s)", strUser, strPassword, strProgram); + + unsigned long num = 0; + if (m_Dongle.Connected()) + { + if (stricmp(strUser,"******")==0 && stricmp(strProgram, "ba0100")==0) + { + num = 1; + } + else + { + if (m_Users.GetCount() >= m_Dongle.MaxUsers()) + num = 0; + else + { + if (strcmp(strPassword, "******") == 0) + num = 1; + else + { + num = DecodePassword(strPassword); + if (num > 0) + m_Users.AddConnection(sock, strUser); + } + } + } + } + ReturnInt(sock, num); +} + +bool TAuthorizationServer::ProcessUserLogout(wxString cmd, wxSocketBase& sock) +{ + const int a = cmd.Find('(')+1; + const int c = cmd.Find(')'); + if (c > a) + { + const wxString strUser = cmd.Mid(a, c-a); + m_Users.RemoveConnection(sock, strUser); + } + return true; +} + +void TAuthorizationServer::ReturnInt(wxSocketBase& outs, unsigned int i) +{ + const unsigned int buf[2] = { sizeof(i), i }; + outs.Write(buf, sizeof(buf)); +} + +void TAuthorizationServer::ReturnBool(wxSocketBase& outs, bool b) +{ + ReturnInt(outs, b ? 1 : 0); +} + +void TAuthorizationServer::ProcessCommand(wxString cmd, wxSocketBase& outs) +{ + if (cmd.StartsWith("GET ")) + { + const int stop = cmd.Find(" HTTP"); + wxString str; + if (stop > 4) + str = cmd.Mid(4, stop-4).Trim(); + else + str = cmd.Mid(4).Trim(); + if (str == "/") + str += "index.htm"; + wxString strFilename = GetDocumentRoot() + str; + + if (IsMagicName(strFilename)) + GenerateFile(strFilename); + + SendFile(strFilename, outs); + } else + if (cmd.StartsWith("POST ")) + { + ProcessFormCommand(cmd, outs); + } else + if (cmd.StartsWith("UserLogin")) + { + ProcessUserLogin(cmd, outs); + } else + if (cmd.StartsWith("UserLogout")) + { + bool ok = ProcessUserLogout(cmd, outs); + ReturnBool(outs, ok); + } else + if (cmd.StartsWith("DongleNumber")) + { + ReturnInt(outs, m_Dongle.Number()); + } else + if (cmd.StartsWith("DongleYear")) + { + ReturnInt(outs, m_Dongle.YearAssist()); + } else + if (cmd.StartsWith("DongleModules")) + { + outs.Write(m_Modules, sizeof(m_Modules)); + } +} + +bool TAuthorizationServer::Initialization() +{ + m_Dongle.Login(); + InitModules(); + + return true; +} + +bool TAuthorizationServer::Deinitialization() +{ + m_Dongle.Logout(); + return true; +} + +// Istanziare l'applicazione principale + +IMPLEMENT_APP(TAuthorizationServer) diff --git a/server/authoriz.dsp b/server/authoriz.dsp new file mode 100755 index 000000000..958032d2d --- /dev/null +++ b/server/authoriz.dsp @@ -0,0 +1,233 @@ +# Microsoft Developer Studio Project File - Name="Authoriz" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=Authoriz - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "Authoriz.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Authoriz.mak" CFG="Authoriz - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Authoriz - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "Authoriz - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE "Authoriz - Win32 Debug DLL" (based on "Win32 (x86) Application") +!MESSAGE "Authoriz - Win32 Release DLL" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Authoriz - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../include" /I "../../contrib/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wx.lib xpm.lib png.lib zlib.lib jpeg.lib tiff.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /nodefaultlib:"msvcrtd.lib" /libpath:"../../lib" /libpath:"../../contrib/lib" + +!ELSEIF "$(CFG)" == "Authoriz - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "\wx229\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FR /FD /c +# SUBTRACT CPP /YX /Yc /Yu +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxd.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /nodefaultlib:"msvcrt.lib" /out:"../exe/servers/Authoriz.exe" /pdbtype:sept /libpath:"/wx229/lib" + +!ELSEIF "$(CFG)" == "Authoriz - Win32 Debug DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "DebugDLL" +# PROP BASE Intermediate_Dir "DebugDLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "DebugDLL" +# PROP Intermediate_Dir "DebugDLL" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../contrib/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /Yu"wx/wxprec.h" /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wx22_9d.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /out:"DebugDLL/server.exe" /pdbtype:sept /libpath:"../../lib" /libpath:"../../contrib/lib" + +!ELSEIF "$(CFG)" == "Authoriz - Win32 Release DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseDLL" +# PROP BASE Intermediate_Dir "ReleaseDLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseDLL" +# PROP Intermediate_Dir "ReleaseDLL" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../include" /I "../../contrib/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /FD /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wx22_9.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /out:"ReleaseDLL/server.exe" /libpath:"../../lib" /libpath:"../../contrib/lib" + +!ENDIF + +# Begin Target + +# Name "Authoriz - Win32 Release" +# Name "Authoriz - Win32 Debug" +# Name "Authoriz - Win32 Debug DLL" +# Name "Authoriz - Win32 Release DLL" +# Begin Group "Sources" + +# PROP Default_Filter "cpp" +# Begin Source File + +SOURCE=.\Authoriz.cpp +# End Source File +# Begin Source File + +SOURCE=.\BaseServ.cpp +# End Source File +# Begin Source File + +SOURCE=.\Dongle.cpp +# End Source File +# Begin Source File + +SOURCE=.\xml.cpp +# End Source File +# End Group +# Begin Group "Headers" + +# PROP Default_Filter "h" +# Begin Source File + +SOURCE=.\BaseServ.h +# End Source File +# Begin Source File + +SOURCE=.\dongle.h +# End Source File +# Begin Source File + +SOURCE=.\hlapi_c.h +# End Source File +# Begin Source File + +SOURCE=.\html.h +# End Source File +# Begin Source File + +SOURCE=.\skeylink.h +# End Source File +# Begin Source File + +SOURCE=.\xml.h +# End Source File +# End Group +# Begin Source File + +SOURCE=.\server.rc + +!IF "$(CFG)" == "Authoriz - Win32 Release" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x809 /i "../../include" /i "../../contrib/include" + +!ELSEIF "$(CFG)" == "Authoriz - Win32 Debug" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x410 /i "c:\wx229\wx" /i /wx229/include" " + +!ELSEIF "$(CFG)" == "Authoriz - Win32 Debug DLL" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x809 /i "../../include" /i "../../contrib/include" + +!ELSEIF "$(CFG)" == "Authoriz - Win32 Release DLL" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x809 /i /wx229/include" " + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=..\Lib\skeylink.obj +# End Source File +# Begin Source File + +SOURCE=..\Lib\hlw32_mc.lib +# End Source File +# End Target +# End Project diff --git a/server/baseserv.cpp b/server/baseserv.cpp new file mode 100755 index 000000000..000f6d72e --- /dev/null +++ b/server/baseserv.cpp @@ -0,0 +1,586 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: BaseServ.cpp +// Purpose: Simple base Server +// Author: Guy +// Modified by: +// Created: 21/08/2002 +// Copyright: (c) 2002 Guy +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// ========================================================================== +// declarations +// ========================================================================== + +// -------------------------------------------------------------------------- +// headers +// -------------------------------------------------------------------------- + +#include "BaseServ.h" + +#include +#include +#include +#include + +#include + +/////////////////////////////////////////////////////////// +// Utilities +/////////////////////////////////////////////////////////// + +wxString Date2String(const wxDateTime& date) +{ + return date.Format("%d-%m-%Y"); +} + +wxDateTime String2Date(const wxString& str) +{ + int d, m, y; + sscanf(str, "%d-%d-%d", &d, &m, &y); + wxDateTime date(d, wxDateTime::Month(m-1), y); + return date; +} + +// -------------------------------------------------------------------------- +// classes +// -------------------------------------------------------------------------- + +/////////////////////////////////////////////////////////// +// THashTable +/////////////////////////////////////////////////////////// + +void THashTable::Put(const wxString& key, const wxString& value) +{ + THashString* entry = new THashString(value); + m_Hash.Put(key, entry); +} + +wxString THashTable::Get(const wxChar* key) const +{ + wxString strValue; + THashString* str = (THashString*)m_Hash.Get(key); + if (str != NULL) + strValue = str->m_str; + return strValue; +} + +THashTable::THashTable(size_t size) : m_Hash(wxKEY_STRING, size) +{ + m_Hash.DeleteContents(true); +} + +/////////////////////////////////////////////////////////// +// TBaseServerApp +/////////////////////////////////////////////////////////// + +TBaseServerApp& GetServerApp() +{ + return (TBaseServerApp&)*wxTheApp; +} + +enum +{ + SERVER_ID = 1001, + SOCKET_ID = 1002 +}; + + +BEGIN_EVENT_TABLE(TBaseServerApp, wxApp) + EVT_SOCKET(SERVER_ID, TBaseServerApp::OnServerEvent) + EVT_SOCKET(SOCKET_ID, TBaseServerApp::OnSocketEvent) +END_EVENT_TABLE() + +void TBaseServerApp::WriteLog(const wxChar* str) const +{ + if (m_log != NULL) + *m_log << str << endl; +} + +wxString TBaseServerApp::GetTempFilename() +{ + wxString strTmp; + if (m_strTempDir.IsEmpty()) + { + const wxString strPrefix = "Srv"; + ::wxGetTempFileName(strPrefix, strTmp); + ::wxRemoveFile(strTmp); + (wxString&)m_strTempDir << ::wxPathOnly(strTmp) << "/"; + } + strTmp = m_strTempDir; + strTmp += wxString::Format("%s_%d.htm", GetAppName(), m_nTmpCounter); + m_nTmpCounter++; + if (m_nTmpCounter >= 8) + m_nTmpCounter = 0; + + return strTmp; +} + +TXmlItem& TBaseServerApp::AddLogo(TXmlItem& tr) const +{ + TXmlItem& td = tr.AddChild("td"); + td.SetAttr("width", "15%"); + td.SetAttr("align", "center"); + + TXmlItem& a = td.AddChild("a"); + a.SetAttr("href", "/index.htm"); + + const wxString gif = GetConfigString("Icon", "euro.gif"); + TXmlItem& img = a.AddChild("img"); + img.SetAttr("src", gif); + img.SetAttr("border", "0"); + img.SetAttr("alt", "Return to Home Page"); + + return td; +} + +TXmlItem& TBaseServerApp::CreatePageBody(TXmlItem& html, wxString header) const +{ + if (header.IsEmpty()) + header << GetAppName() << " Server"; + + html.SetTag("html"); + + TXmlItem& head = html.AddChild("head"); + TXmlItem& meta1 = head.AddChild("meta"); + meta1.SetAttr("name", "GENERATOR"); + meta1.SetAttr("content", GetAppName()); + TXmlItem& meta2 = head.AddChild("meta"); + meta2.SetAttr("HTTP-EQUIV", "Content-Type"); + meta2.SetAttr("content", "text/html; charset=iso-8859-1"); + head.AddChild("title") << header; + + TXmlItem& body = html.AddChild("body"); + body.SetAttr("bgcolor", "#E0E080"); + body.SetAttr("background", "back.gif"); + + TXmlItem& title = body.AddChild("table"); + title.SetAttr("border", "5"); title.SetAttr("width", "100%"); + TXmlItem& title_tr = title.AddChild("tr"); + + if (m_bRunning) + AddLogo(title_tr); + + TXmlItem& td1 = title_tr.AddChild("td"); + td1.AddChild("h1").AddChild("center") << header; + + if (m_bRunning) + AddLogo(title_tr); + + body.AddChild("br"); + return body; +} + +TXmlItem& TBaseServerApp::AddLinkButton(TXmlItem& body, const wxChar* strCaption, const wxChar* strHref) const +{ + TXmlItem& table = body.AddChild("table"); + table.SetAttr("border", "2"); table.SetAttr("bgcolor", "#C0C0C0"); + + TXmlItem& td = table.AddChild("tr").AddChild("td"); + td.SetAttr("align", "center"); + td.AddChild("a").SetAttr("href", strHref) << strCaption; + + return table; +} + +void TBaseServerApp::MessageBox(const wxChar* caption, const wxChar* msg, wxSocketBase& outs) +{ + TXmlItem html; + TXmlItem& body = CreatePageBody(html); + + TXmlItem& table = body.AddChild("center").AddChild("table"); + table.SetAttr("width", "70%"); table.SetAttr("border", "2"); + table.AddChild("caption").AddChild("h2") << caption; + + TXmlItem& td0 = table.AddChild("tr").AddChild("td"); + td0.SetAttr("align", "justify"); + td0.AddChild("h3") << msg; + + TXmlItem& td1 = table.AddChild("tr").AddChild("td"); + td1.SetAttr("align", "center"); + AddLinkButton(td1, "Return to main page", "index.htm"); + + const wxString strTmp = GetTempFilename(); + html.Save(strTmp); + SendFile(strTmp, outs); +} + +bool TBaseServerApp::CanProcessCommand(wxString& cmd, wxSocketBase& outs) +{ + if (cmd.Find("stop.cgi") > 0) + { + m_bRunning = false; // Disable gif on title + MessageBox("Warning!", "Server Stopped", outs); + ExitMainLoop(); + return false; + } + + return true; +} + +void TBaseServerApp::SendFile(wxString strFilename, wxSocketBase& sock) +{ + const bool bFound = wxFileExists(strFilename); + if (!bFound) + { + const wxString strTmp = GetTempFilename(); + if (!strTmp.IsEmpty()) + { + TXmlItem html; + TXmlItem& body = CreatePageBody(html); + body.AddChild("h1") << "Sorry: File not found!"; + body.AddChild("br"); + body.AddChild("h2") << strFilename; + html.Save(strTmp); + } + strFilename = strTmp; + } + + wxFileInputStream inf(strFilename); + + const size_t nSize = inf.GetSize(); + + WriteLog(wxString::Format("Sending %s (%u bytes)", strFilename, nSize)); + + wxString strType; + wxSplitPath(strFilename, NULL, NULL, &strType); + wxFileType* type = wxTheMimeTypesManager->GetFileTypeFromExtension(strType); + if (type != NULL) + type->GetMimeType(&strType); + else + strType = "text/plain"; + const wxDateTime date = ::wxFileModificationTime(strFilename); + + wxSocketOutputStream outs(sock); + if (bFound) + { + outs << "HTTP/1.1 200 OK" << endl; + } + else + { + outs << "HTTP/1.1 401 Not found" << endl; + } + outs << "Server: " << GetAppName() << endl; + outs << "Host: " << wxGetHostName() << endl; + if (bFound && m_bRunning) + { + outs << "Connection: keep-alive" << endl; + } + else + { + outs << "Connection: close" << endl; + } + outs << "Content-Type: " << strType << endl; + outs << "Content-Length: " << wxString::Format("%u", nSize) << endl; + outs << "Date: " << date.Format("%#c") << endl; + outs << endl; + + const size_t BUF_TEMP_SIZE = 1024*64; + char* buf = new char[BUF_TEMP_SIZE]; + size_t bytes = BUF_TEMP_SIZE; + size_t nTotal = 0; + while (bytes == BUF_TEMP_SIZE) + { + bytes = inf.Read(buf, bytes).LastRead(); + bytes = outs.Write(buf, bytes).LastWrite(); + // if (bytes == BUF_TEMP_SIZE) wxSleep(1); + sock.WaitForWrite(5); + nTotal += bytes; + } + delete buf; + + if (nTotal < nSize) + { + WriteLog(wxString::Format("I sent %u bytes only.", nTotal)); + } +} + +const wxChar* TBaseServerApp::GetAppName() const +{ + // Pure virtual function + return "Server"; +} + +void TBaseServerApp::ProcessCommand(wxString cmd, wxSocketBase& outs) +{ + // Pure virtual function + WriteLog("Processing..."); + SendFile("index.htm", outs); +} + +void TBaseServerApp::OnServerEvent(wxSocketEvent& event) +{ + wxString s = "OnServerEvent: "; + + switch(event.GetSocketEvent()) + { + case wxSOCKET_CONNECTION : s.Append("wxSOCKET_CONNECTION"); break; + default : s.Append("Unexpected event!"); break; + } + + WriteLog(s); + + // Accept new connection if there is one in the pending + // connections queue, else exit. We use Accept(FALSE) for + // non-blocking accept (although if we got here, there + // should ALWAYS be a pending connection). + + wxSocketBase* sock = m_server->Accept(FALSE); + if (sock) + { + WriteLog("New client connection accepted"); + } + else + { + WriteLog("Error: couldn't accept a new connection"); + sock->Destroy(); + return; + } + + sock->SetEventHandler(*this, SOCKET_ID); + sock->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG); + sock->Notify(TRUE); +} + +void TBaseServerApp::OnSocketEvent(wxSocketEvent& event) +{ + wxString s = "OnSocketEvent: "; + wxSocketBase *sock = event.GetSocket(); + + // First, print a message + switch(event.GetSocketEvent()) + { + case wxSOCKET_INPUT : s.Append("wxSOCKET_INPUT\n"); break; + case wxSOCKET_LOST : s.Append("wxSOCKET_LOST\n"); break; + default : s.Append("Unexpected event !\n"); break; + } + + WriteLog(s); + + // Now we process the event + switch(event.GetSocketEvent()) + { + case wxSOCKET_INPUT: + { + const int nOldFlags = sock->GetFlags(); + // We disable input events, so that the test doesn't trigger + // wxSocketEvent again. + sock->SetNotify(wxSOCKET_LOST_FLAG); + sock->SetFlags(wxSOCKET_NOWAIT); // Non aspettare troppo + + // Read the data + const size_t BUFSIZE = 2048; + wxString str; + wxChar* buf = str.GetWriteBuf(BUFSIZE); + memset(buf, 0, BUFSIZE); + const size_t len = sock->Read(buf, BUFSIZE).LastCount(); + str.UngetWriteBuf(len+1); + + WriteLog(str); + + sock->SetFlags(nOldFlags); // Ripristina flags + if (CanProcessCommand(str, *sock)) + ProcessCommand(str, *sock); + + // Enable input events again. + sock->SetNotify(wxSOCKET_LOST_FLAG | wxSOCKET_INPUT_FLAG); + break; + } + case wxSOCKET_LOST: + { + // Destroy() should be used instead of delete wherever possible, + // due to the fact that wxSocket uses 'delayed events' (see the + // documentation for wxPostEvent) and we don't want an event to + // arrive to the event handler (the frame, here) after the socket + // has been deleted. Also, we might be doing some other thing with + // the socket at the same time; for example, we might be in the + // middle of a test or something. Destroy() takes care of all + // this for us. + + WriteLog("Deleting socket."); + sock->Destroy(); + break; + } + default: ; + } +} + +const wxChar* TBaseServerApp::GetConfigName() const +{ + return "./servers.ini"; +} + +void TBaseServerApp::SetConfigString(const wxChar* key, const wxChar* val, const wxChar* app) const +{ + wxIniConfig ini("", "", GetConfigName()); + wxString str; + if (app == NULL || *app == '\0') + app = GetAppName(); + str << '/' << app; + ini.SetPath(str); + ini.Write(key, val); +} + +void TBaseServerApp::SetConfigInt(const wxChar* key, int val, const wxChar* app) const +{ + wxString str = wxString::Format("%d", val); + SetConfigString(key, str, app); +} + +wxString TBaseServerApp::GetConfigString(const wxChar* key, const wxChar* def, const wxChar* app) const +{ + wxIniConfig ini("", "", GetConfigName()); + wxString str; + if (app == NULL || *app == '\0') + app = GetAppName(); + str << '/' << app; + ini.SetPath(str); + ini.Read(key, &str, def); + return str; +} + +int TBaseServerApp::GetConfigInt(const wxChar* key, int def, const wxChar* app) const +{ + wxString str = GetConfigString(key, "*", app); + int val = def; + if (str != "*") + val = atoi(str); + return val; +} + +bool TBaseServerApp::GetConfigBool(const wxChar* key, bool def, const wxChar* app) const +{ + wxString str = GetConfigString(key, "*", app); + bool val = def; + if (str != "*") + val = (str[0] == '1') || (str[0] == 'X') || (str[0] == 'Y'); + return val; +} + +int TBaseServerApp::GetDefaultPort() const +{ + return GetConfigInt("Port", 3883); +} + +wxString TBaseServerApp::GetLogFileName() const +{ + return GetConfigString("LogFile"); +} + +wxString TBaseServerApp::GetDocumentRoot() const +{ + return GetConfigString("DocumentRoot", "."); +} + +bool TBaseServerApp::OnInit() +{ + // Create the address - defaults to localhost:0 initially + wxIPV4address addr; + addr.Service(GetDefaultPort()); + // Create the socket + m_server = new wxSocketServer(addr); + + // Create the Log file + wxString str; + + str = GetLogFileName(); + if (!str.IsEmpty()) + m_log = new wxFileOutputStream(str); + else + m_log = NULL; + + m_nTmpCounter = 0; + + // We use Ok() here to see if the server is really listening + str.Empty(); + if (m_server->Ok()) + { + // Setup the event handler and subscribe to connection events + m_server->SetEventHandler(*this, SERVER_ID); + m_server->SetNotify(wxSOCKET_CONNECTION_FLAG); + m_server->Notify(TRUE); + + str << GetAppName() << " listening on port " << addr.Service(); + SetConfigString("Running", "1"); + m_bRunning = true; + } + else + { + str << GetAppName() << " could not listen to port " << addr.Service(); + } + WriteLog(str); + + bool ok = m_server->Ok(); + if (ok) + ok = Initialization(); + + return ok; +} + +int TBaseServerApp::OnExit() +{ + Deinitialization(); + + if (m_server != NULL) + delete m_server; + if (m_log != NULL) + { + SetConfigString("Running", ""); + wxString str; + str << GetAppName() << " shutting down."; + WriteLog(str); + delete m_log; + } + return wxApp::OnExit(); +} + +wxString TBaseServerApp::UnformatString(const wxString& strFormString) const +{ + wxString strResult; + for (int i = 0; strFormString[i]; i++) + { + switch(strFormString[i]) + { + case '+': + strResult += ' '; break; + case '%': + { + const wxChar c = hex2int(strFormString.Mid(i+1, 2)); + strResult += c; + i += 2; + } + break; + default: + strResult += strFormString[i]; break; + } + } + return strResult; +} + +int TBaseServerApp::ParseArguments(wxString args, THashTable& hashArgs) const +{ + int uguale = args.Find('='); + while (uguale > 0) + { + wxString name = args.Left(uguale); + name.Trim(false); name.Trim(true); + + wxString value; + const int acapo = args.Find('&'); + if (acapo > uguale) + value = args.Mid(uguale+1, acapo-uguale-1); + else + value = args.Mid(uguale+1); + value.Trim(false); value.Trim(true); + hashArgs.Put(name, UnformatString(value)); + + if (acapo > 0) + { + args = args.Mid(acapo+1); + uguale = args.Find('='); + } + else + uguale = -1; + } + return hashArgs.GetCount(); +} diff --git a/server/baseserv.dsp b/server/baseserv.dsp new file mode 100755 index 000000000..77a17ab33 --- /dev/null +++ b/server/baseserv.dsp @@ -0,0 +1,205 @@ +# Microsoft Developer Studio Project File - Name="BaseServ" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=BaseServ - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "BaseServ.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "BaseServ.mak" CFG="BaseServ - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "BaseServ - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "BaseServ - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE "BaseServ - Win32 Debug DLL" (based on "Win32 (x86) Application") +!MESSAGE "BaseServ - Win32 Release DLL" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "BaseServ - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../include" /I "../../contrib/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wx.lib xpm.lib png.lib zlib.lib jpeg.lib tiff.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /nodefaultlib:"msvcrtd.lib" /out:"Release/server.exe" /libpath:"../../lib" /libpath:"../../contrib/lib" + +!ELSEIF "$(CFG)" == "BaseServ - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "\wx229\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FR /FD /c +# SUBTRACT CPP /YX /Yc /Yu +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxd.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /nodefaultlib:"msvcrt.lib" /out:"Debug/server.exe" /pdbtype:sept /libpath:"/wx229/lib" + +!ELSEIF "$(CFG)" == "BaseServ - Win32 Debug DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "DebugDLL" +# PROP BASE Intermediate_Dir "DebugDLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "DebugDLL" +# PROP Intermediate_Dir "DebugDLL" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../contrib/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /Yu"wx/wxprec.h" /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wx22_9d.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /out:"DebugDLL/server.exe" /pdbtype:sept /libpath:"../../lib" /libpath:"../../contrib/lib" + +!ELSEIF "$(CFG)" == "BaseServ - Win32 Release DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseDLL" +# PROP BASE Intermediate_Dir "ReleaseDLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseDLL" +# PROP Intermediate_Dir "ReleaseDLL" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../include" /I "../../contrib/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /FD /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wx22_9.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /out:"ReleaseDLL/server.exe" /libpath:"../../lib" /libpath:"../../contrib/lib" + +!ENDIF + +# Begin Target + +# Name "BaseServ - Win32 Release" +# Name "BaseServ - Win32 Debug" +# Name "BaseServ - Win32 Debug DLL" +# Name "BaseServ - Win32 Release DLL" +# Begin Group "Sources" + +# PROP Default_Filter "cpp" +# Begin Source File + +SOURCE=.\BaseServ.cpp +# End Source File +# Begin Source File + +SOURCE=.\Example.cpp +# End Source File +# Begin Source File + +SOURCE=.\xml.cpp +# End Source File +# End Group +# Begin Group "Headers" + +# PROP Default_Filter "h" +# Begin Source File + +SOURCE=.\BaseServ.h +# End Source File +# Begin Source File + +SOURCE=.\xml.h +# End Source File +# End Group +# Begin Source File + +SOURCE=.\server.rc + +!IF "$(CFG)" == "BaseServ - Win32 Release" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x809 /i "../../include" /i "../../contrib/include" + +!ELSEIF "$(CFG)" == "BaseServ - Win32 Debug" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x410 /i "c:\wx229\wx" /i /wx229/include" " + +!ELSEIF "$(CFG)" == "BaseServ - Win32 Debug DLL" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x809 /i "../../include" /i "../../contrib/include" + +!ELSEIF "$(CFG)" == "BaseServ - Win32 Release DLL" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x809 /i /wx229/include" " + +!ENDIF + +# End Source File +# End Target +# End Project diff --git a/server/baseserv.h b/server/baseserv.h new file mode 100755 index 000000000..178ab1c77 --- /dev/null +++ b/server/baseserv.h @@ -0,0 +1,105 @@ +#include +#include +#include +#include +#include "xml.h" + + +////////////////////////////////////////////////////////// +// Utilities +/////////////////////////////////////////////////////////// + +wxString Date2String(const wxDateTime& date); +wxDateTime String2Date(const wxString& str); + +////////////////////////////////////////////////////////// +// THashString +/////////////////////////////////////////////////////////// + +class THashString : public wxObject +{ +public: + wxString m_str; + THashString(const wxChar* str) : m_str(str) { } +}; + +////////////////////////////////////////////////////////// +// THashTable +/////////////////////////////////////////////////////////// + +class THashTable : public wxObject +{ + wxHashTable m_Hash; + +public: + void Put(const wxString& key, const wxString& value); + wxString Get(const wxChar* key) const; + int GetInt(const wxChar* key) const { return atoi(Get(key)); } + wxDateTime GetDate(const wxChar* key) const { return String2Date(Get(key)); } + + size_t GetCount() const { return m_Hash.GetCount(); } + void BeginFind() { m_Hash.BeginFind(); } + wxNode* Next() { return m_Hash.Next(); } + + THashTable(size_t size = 13); +}; + +////////////////////////////////////////////////////////// +// TBaseServerApp +/////////////////////////////////////////////////////////// + +// Define a new application type +class TBaseServerApp : public wxApp +{ +private: + wxSocketServer* m_server; + wxFileOutputStream* m_log; + wxString m_strTempDir; + bool m_bRunning; + int m_nTmpCounter; + +protected: + // Pure virtual functions! + virtual const wxChar* GetAppName() const = 0; + virtual void ProcessCommand(wxString cmd, wxSocketBase& outs) = 0; + + virtual bool CanProcessCommand(wxString& cmd, wxSocketBase& outs); + + virtual int GetDefaultPort() const; // Retrieves Port usig GetConfigInt + virtual wxString GetLogFileName() const; // Retrieves Port usig GetConfigString + virtual wxString GetDocumentRoot() const; // Retrieves Port usig GetConfigString + + TXmlItem& AddLogo(TXmlItem& td) const; + +public: + // Utilities + virtual const wxChar* GetConfigName() const; + virtual void SetConfigString(const wxChar* key, const wxChar* val, const wxChar* app = NULL) const; + void SetConfigInt(const wxChar* key, int val, const wxChar* app = NULL) const; + virtual wxString GetConfigString(const wxChar* key, const wxChar* def = "", const wxChar* app = NULL) const; + int GetConfigInt(const wxChar* key, int def = 0, const wxChar* app = NULL) const; // Uses GetConfigString + bool GetConfigBool(const wxChar* key, bool def = false, const wxChar* app = NULL) const; // Uses GetConfigString + wxString GetTempFilename(); + TXmlItem& CreatePageBody(TXmlItem& html, wxString header = "") const; + TXmlItem& AddLinkButton(TXmlItem& body, const wxChar* strCaption, const wxChar* strHref) const; + + void SendFile(wxString strFilename, wxSocketBase& outs); + void MessageBox(const wxChar* caption, const wxChar* msg, wxSocketBase& outs); + + wxString UnformatString(const wxString& strFormString) const; + int ParseArguments(wxString args, THashTable& hashArgs) const; + + virtual void WriteLog(const wxChar* str) const; // Writes on log file if present + virtual bool Ok() const { return m_server->Ok(); } + virtual bool Initialization() { return true; } + virtual bool Deinitialization() { return true; } + + // Initialization (Do NOT use nor reimplement!) + virtual bool OnInit(); + virtual int OnExit(); + void OnServerEvent(wxSocketEvent& event); + void OnSocketEvent(wxSocketEvent& event); + DECLARE_EVENT_TABLE(); +}; + +TBaseServerApp& GetServerApp(); diff --git a/server/coffee.cpp b/server/coffee.cpp new file mode 100755 index 000000000..cbc339856 --- /dev/null +++ b/server/coffee.cpp @@ -0,0 +1,81 @@ +#include "BaseServ.h" + +class TCoffeeServer : public TBaseServerApp +{ +protected: + virtual const wxChar* GetAppName() const; + virtual void ProcessCommand(wxString cmd, wxSocketBase& outs); + +public: + bool IsMagicName(wxString& strFilename) const; + void GenerateFile(wxString& strFilename); +}; + +// Implementare almeno queste due funzioni pure virtuali + +const wxChar* TCoffeeServer::GetAppName() const +{ + return "Coffee"; +} + +bool TCoffeeServer::IsMagicName(wxString& strFilename) const +{ + wxString strName; + wxSplitPath(strFilename, NULL, &strName, NULL); + strName.MakeLower(); + if (strName == "index") + { + strFilename = strName; + return true; + } + if (strName == "log") + { + strFilename = GetLogFileName(); + } + + return false; +} + +void TCoffeeServer::GenerateFile(wxString& strFilename) +{ + wxString strName; + wxSplitPath(strFilename, NULL, &strName, NULL); + strName.MakeLower(); + if (strName == "index") + { + TXmlItem html; + TXmlItem& body = CreatePageBody(html); + + TXmlItem& cen = body.AddChild("h1").AddChild("center"); + cen << "Just Kidding :-)"; + cen.AddChild("br"); + cen.AddChild("img").SetAttr("src", GetConfigString("Icon")); + strFilename = GetTempFilename(); + body.Save(strFilename); + } + if (strName == "log") + { + strFilename = GetLogFileName(); + } +} + +void TCoffeeServer::ProcessCommand(wxString cmd, wxSocketBase& outs) +{ + if (cmd.StartsWith("GET ")) + { + const int stop = cmd.Find(" HTTP"); + wxString str = cmd.Mid(4, stop-4).Trim(); + if (str == "/") + str += "index.htm"; + wxString strFilename = GetDocumentRoot() + str; + + if (IsMagicName(strFilename)) + GenerateFile(strFilename); + + SendFile(strFilename, outs); + } +} + +// Istanziare l'applicazione principale + +IMPLEMENT_APP(TCoffeeServer) diff --git a/server/coffee.dsp b/server/coffee.dsp new file mode 100755 index 000000000..bce4f82a1 --- /dev/null +++ b/server/coffee.dsp @@ -0,0 +1,209 @@ +# Microsoft Developer Studio Project File - Name="Coffee" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=Coffee - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "Coffee.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Coffee.mak" CFG="Coffee - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Coffee - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "Coffee - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE "Coffee - Win32 Debug DLL" (based on "Win32 (x86) Application") +!MESSAGE "Coffee - Win32 Release DLL" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Coffee - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../include" /I "../../contrib/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wx.lib xpm.lib png.lib zlib.lib jpeg.lib tiff.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /nodefaultlib:"msvcrtd.lib" /libpath:"../../lib" /libpath:"../../contrib/lib" + +!ELSEIF "$(CFG)" == "Coffee - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "\wx229\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FR /FD /c +# SUBTRACT CPP /YX /Yc /Yu +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxd.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /nodefaultlib:"msvcrt.lib" /out:"../exe/servers/Coffee.exe" /pdbtype:sept /libpath:"/wx229/lib" + +!ELSEIF "$(CFG)" == "Coffee - Win32 Debug DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "DebugDLL" +# PROP BASE Intermediate_Dir "DebugDLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "DebugDLL" +# PROP Intermediate_Dir "DebugDLL" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../contrib/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /Yu"wx/wxprec.h" /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wx22_9d.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /out:"DebugDLL/server.exe" /pdbtype:sept /libpath:"../../lib" /libpath:"../../contrib/lib" + +!ELSEIF "$(CFG)" == "Coffee - Win32 Release DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseDLL" +# PROP BASE Intermediate_Dir "ReleaseDLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseDLL" +# PROP Intermediate_Dir "ReleaseDLL" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../include" /I "../../contrib/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /FD /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wx22_9.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /out:"ReleaseDLL/server.exe" /libpath:"../../lib" /libpath:"../../contrib/lib" + +!ENDIF + +# Begin Target + +# Name "Coffee - Win32 Release" +# Name "Coffee - Win32 Debug" +# Name "Coffee - Win32 Debug DLL" +# Name "Coffee - Win32 Release DLL" +# Begin Group "Sources" + +# PROP Default_Filter "cpp" +# Begin Source File + +SOURCE=.\BaseServ.cpp +# End Source File +# Begin Source File + +SOURCE=.\Coffee.cpp +# End Source File +# Begin Source File + +SOURCE=.\xml.cpp +# End Source File +# End Group +# Begin Group "Headers" + +# PROP Default_Filter "h" +# Begin Source File + +SOURCE=.\BaseServ.h +# End Source File +# Begin Source File + +SOURCE=.\Coffee.h +# End Source File +# Begin Source File + +SOURCE=.\xml.h +# End Source File +# End Group +# Begin Source File + +SOURCE=.\server.rc + +!IF "$(CFG)" == "Coffee - Win32 Release" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x809 /i "../../include" /i "../../contrib/include" + +!ELSEIF "$(CFG)" == "Coffee - Win32 Debug" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x410 /i "c:\wx229\wx" /i /wx229/include" " + +!ELSEIF "$(CFG)" == "Coffee - Win32 Debug DLL" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x809 /i "../../include" /i "../../contrib/include" + +!ELSEIF "$(CFG)" == "Coffee - Win32 Release DLL" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x809 /i /wx229/include" " + +!ENDIF + +# End Source File +# End Target +# End Project diff --git a/server/diction.cpp b/server/diction.cpp index 0d926dd85..5e01a1d14 100755 --- a/server/diction.cpp +++ b/server/diction.cpp @@ -1,28 +1,12 @@ -#include -#include -#include - -#include -#include +#include "BaseServ.h" +#include +#include +#include #include -#include "Soap.h" -#include "Diction.h" - ////////////////////////////////////////////////////////// -// TDictionaryEntry -/////////////////////////////////////////////////////////// - -class TDictionaryEntry : public wxObject -{ -public: - wxString m_str; - TDictionaryEntry(const wxChar* str) : m_str(str) { } -}; - -////////////////////////////////////////////////////////// -// Sorted array of TDictionaryEntry +// Sorted array of THashString /////////////////////////////////////////////////////////// static int CompareNodes(wxNode** n1, wxNode** n2) @@ -36,32 +20,41 @@ WX_DEFINE_ARRAY(wxNode*, TArrayOfNodes); // TDictionary /////////////////////////////////////////////////////////// -class TDictionary : public wxHashTable +class TDictionary : public THashTable { - bool m_bDirty; + unsigned int m_nNewEntries; + TArrayOfNodes m_sorted; protected: + void ParseSpaces(const wxString& str, wxString& prefix, + wxString& body, wxString& postfix) const; wxString Accentuate(const wxString& str) const; - const TDictionaryEntry* AddEntry(const wxString& ita, const wxChar* eng); - wxString GetFileName() const; + void AddEntry(const wxString& ita, const wxString& eng); static bool FillCallback(TXmlItem& item, long jolly); bool Load(); + void Save(); public: - wxString Translate(const wxString& ita, const wxString& lan); + wxString Translate(const wxString& ita); + + wxString GetFileName() const; + bool LoadIfEmpty(); + bool SortIfNeeded(); + void SaveIfNeeded(); + + wxString OriginalEntry(size_t i); + wxString TranslatedEntry(size_t i); + void UpdateEntry(size_t i, const wxString& strValue); + TDictionary(); ~TDictionary(); }; -static TDictionary DevotoOli; - wxString TDictionary::GetFileName() const { - wxIniConfig ini("", "", "./server.ini"); - ini.SetPath("/Dictionary"); - wxString fname = ini.Read("FileName", "campo.dic"); - return fname; + TBaseServerApp& app = (TBaseServerApp&)*wxTheApp; + return app.GetConfigString("Dictionary", "campodic.xml"); } wxString TDictionary::Accentuate(const wxString& str) const @@ -107,13 +100,64 @@ wxString TDictionary::Accentuate(const wxString& str) const return bello; } -const TDictionaryEntry* TDictionary::AddEntry(const wxString& ita, const wxChar* eng) +void TDictionary::Save() +{ + const bool full = SortIfNeeded(); + if (full) + { + wxFileOutputStream outf(GetFileName()); + outf << "\n"; + for (size_t i = 0; i < m_sorted.GetCount(); i++) + { + const wxNode* pNode = m_sorted[i]; + outf << " \n"; + outf << " "; + WriteXmlString(outf, pNode->GetKeyString()); + outf << "\n"; + outf << " "; + WriteXmlString(outf, ((THashString*)pNode->GetData())->m_str); + outf << "\n"; + outf << " \n"; + } + outf << "\n"; + m_nNewEntries = 0; + } +} + +void TDictionary::SaveIfNeeded() +{ + if (m_nNewEntries > 0) + Save(); +} + +void TDictionary::AddEntry(const wxString& ita, const wxString& eng) { const wxString key = Accentuate(ita); - TDictionaryEntry* entry = new TDictionaryEntry(eng); - Put(key, entry); - m_bDirty = true; - return entry; + Put(key, eng); + m_nNewEntries++; +} + +void TDictionary::UpdateEntry(size_t nEntry, const wxString& strValue) +{ + if (nEntry >= 0 && nEntry < m_sorted.GetCount()) + { + const wxNode* pNode = m_sorted[nEntry]; + ((THashString*)pNode->GetData())->m_str = strValue; + Save(); + } +} + +wxString TDictionary::OriginalEntry(size_t i) +{ + SortIfNeeded(); + const wxNode* pNode = m_sorted[i]; + return pNode->GetKeyString(); +} + +wxString TDictionary::TranslatedEntry(size_t i) +{ + const wxNode* pNode = m_sorted[i]; + return ((THashString*)pNode->GetData())->m_str; } wxSocketClient& operator<<(wxSocketClient& sock, const wxChar* str) @@ -152,71 +196,538 @@ bool TDictionary::Load() item.Read(inf); item.ForEach(FillCallback, (long)this); } - m_bDirty = false; // No last minute additions :-) + m_nNewEntries = 0; // No last minute additions :-) return GetCount() > 0; } -wxString TDictionary::Translate(const wxString& ita, const wxString& lan) +bool TDictionary::LoadIfEmpty() { - if (GetCount() == 0) - Load(); + bool full = GetCount() > 0; + if (!full) + full = Load(); + return full; +} - const wxString key = Accentuate(ita); - TDictionaryEntry* eng = (TDictionaryEntry*)Get(key); - if (eng != NULL) +bool TDictionary::SortIfNeeded() +{ + const bool full = LoadIfEmpty(); + if (m_sorted.GetCount() != GetCount()) { - if (eng->m_str != "???") - return eng->m_str; + // Fill an array of nodes and sort them out + m_sorted.Empty(); + BeginFind(); + for (wxNode* pNode = Next(); pNode != NULL; pNode = Next()) + m_sorted.Add(pNode); + m_sorted.Sort(CompareNodes); + } + return full; +} + + +inline bool IsTrimmable(wxChar c) +{ + return strchr(" :.,;", c) != NULL; +} + +void TDictionary::ParseSpaces(const wxString& str, wxString& prefix, + wxString& body, wxString& postfix) const +{ + int i, j; + for (i = 0; IsTrimmable(str[i]); i++); + for (j = str.Length()-1; j >= i && IsTrimmable(str[j]); j--); + if (i > 0) + prefix = str.Left(i); + if (j >= i) + postfix = str.Mid(j+1); + body = Accentuate(str.Mid(i, j-i+1)); +} + +wxString TDictionary::Translate(const wxString& ita) +{ + LoadIfEmpty(); + + wxString prefix, body, postfix; + ParseSpaces(ita, prefix, body, postfix); + wxString eng = Get(body); + if (!eng.IsEmpty()) + { + if (eng != "???") + { + body = prefix; + body += eng; + body += postfix; + return body; + } } else AddEntry(ita, "???"); - return key; + return ita; } -TDictionary::TDictionary() : wxHashTable(wxKEY_STRING, 883), m_bDirty(false) -{ } +TDictionary::TDictionary() : THashTable(3883), m_nNewEntries(0) +{ +} TDictionary::~TDictionary() { - DeleteContents(true); - - if (m_bDirty) - { - // Fill an array of nodes and sort them out - TArrayOfNodes arr; - BeginFind(); - for (wxNode* pNode = Next(); pNode != NULL; pNode = Next()) - arr.Add(pNode); - arr.Sort(CompareNodes); - - wxFileOutputStream outf(GetFileName()); - outf << "\n"; - for (size_t i = 0; i < arr.GetCount(); i++) - { - const wxNode* pNode = arr[i]; - outf << " \n"; - outf << " " << pNode->GetKeyString() << "\n"; - outf << " " << ((TDictionaryEntry*)pNode->GetData())->m_str << "\n"; - outf << " \n"; - } - outf << "\n"; - } + if (m_nNewEntries > 0) + Save(); } -bool DoTranslate(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer) +/////////////////////////////////////////////////////////// +// TDictionaryServer +/////////////////////////////////////////////////////////// + +class TDictionaryServer : public TBaseServerApp +{ + TDictionary m_DevotoOli; + +protected: + virtual const wxChar* GetAppName() const; + virtual void ProcessCommand(wxString cmd, wxSocketBase& outs); + +public: + bool DoTranslate(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer); + bool SoapProcessMethod(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer); + void ProcessSoapCommand(wxString cmd, wxSocketBase& outs); + void ProcessHttpGet(wxString cmd, wxSocketBase& outs); + void ProcessFormCommand(wxString cmd, wxSocketBase& outs); + + void ProcessFormUpdateEntry(wxString& strFileName, THashTable& hashArgs); + void ProcessFormTranslate(wxString& strFileName, THashTable& hashArgs); + + void CallCgi(wxString& strFilename); + bool IsMagicName(wxString& strFilename) const; + bool IsCgiName(wxString strFilename) const; + + void Add2Columns(TXmlItem& table, const wxChar* href0, const wxChar* td0, const wxChar* td1) const; + void AddEditableRow(TXmlItem& table, const wxChar* txt1, const wxChar* txt2) const; + void GenerateIndex(TXmlItem& body); + void GenerateFile(wxString& strFilename); + + virtual bool Initialize(); + virtual bool Deinitialize(); +}; + +bool TDictionaryServer::SoapProcessMethod(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer) +{ + const wxString& strMethod = xmlMethod.GetTag(); + if (strMethod == "m:Translate") + return DoTranslate(xmlMethod, xmlAnswer); + + return false; +} + +bool TDictionaryServer::DoTranslate(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer) { const TXmlItem* xmlSentence = xmlMethod.FindFirst("sentence"); - // const TXmlItem* xmlLanguage = xmlMethod.FindFirst("language"); - if (xmlSentence != NULL /* && xmlLanguage != NULL */) + if (xmlSentence != NULL) { const wxString ita = xmlSentence->GetEnclosedText(); - const wxString lan; // = xmlLanguage->GetEnclosedText(); - wxString result = DevotoOli.Translate(ita, lan); + wxString result = m_DevotoOli.Translate(ita); xmlAnswer.AddSoapString("sentence", result); return true; } return false; } +bool TDictionaryServer::IsMagicName(wxString& strFilename) const +{ + wxString strName; + wxSplitPath(strFilename, NULL, &strName, NULL); + strName.MakeLower(); + const int q = strName.Find('?'); + if (q > 0) + strName.Truncate(q); + + if (strName == "index" || strName == "dictionary") + { + return true; + } + if (strName == "log") + { + strFilename = GetLogFileName(); + } + + return false; +} + +bool TDictionaryServer::IsCgiName(wxString strFilename) const +{ + const int q = strFilename.Find('?'); + if (q > 0) + strFilename = strFilename.Left(q); + + wxString strExt; + wxSplitPath(strFilename, NULL, NULL, &strExt); + strExt.MakeLower(); + return strExt == "cgi" || strExt == "exe"; +} + +void TDictionaryServer::Add2Columns(TXmlItem& table, const wxChar* href0, const wxChar* txt0, const wxChar* txt1) const +{ + TXmlItem& tr = table.AddChild("tr"); + TXmlItem& a = tr.AddChild("td").AddChild("a"); + a.SetAttr("href", href0); + a << txt0; + tr.AddChild("td") << txt1; +} + +void TDictionaryServer::GenerateIndex(TXmlItem& body) +{ + m_DevotoOli.SortIfNeeded(); + + TXmlItem& table = body.AddChild("table"); + table.SetAttr("border", "1"); table.SetAttr("width", "100%"); + TXmlItem& tr = table.AddChild("tr"); + + wxChar cLast = '\0'; + for (size_t i = 0; i < m_DevotoOli.GetCount(); i++) + { + const wxChar cCurr = toupper(m_DevotoOli.OriginalEntry(i)[0]); + if (cCurr > cLast) + { + TXmlItem& td = tr.AddChild("td").SetAttr("align", "center"); + td.AddChild("a").SetAttr("href", wxString::Format("Dictionary?%c", cCurr)); + td << wxString::Format("%c", cCurr); + cLast = cCurr; + } + } + body.AddChild("br"); +} + +void TDictionaryServer::AddEditableRow(TXmlItem& table, const wxChar* txt1, const wxChar* txt2) const +{ + TXmlItem& tr = table.AddChild("tr"); + TXmlItem& td0 = tr.AddChild("td"); + const wxString cgi = wxString::Format("EditEntry.cgi?%c-%u", + toupper(*txt1), table.GetChildren()-3); + AddLinkButton(td0, "Edit", cgi).SetAttr("width", "100%"); + tr.AddChild("td") << txt1; + tr.AddChild("td") << txt2; +} + +void TDictionaryServer::GenerateFile(wxString& strFilename) +{ + const int q = strFilename.Find('?'); + wxString strArgs; + if (q > 0) + { + strArgs = strFilename.Mid(q+1); + strFilename.Truncate(q); + } + + wxString strName; + wxSplitPath(strFilename, NULL, &strName, NULL); + strName.MakeLower(); + + TXmlItem html; + TXmlItem& body = CreatePageBody(html); + + if (strName == "index") + { + TXmlItem& table = body.AddChild("center").AddChild("table"); + table.SetAttr("border", "1"); table.SetAttr("width", "70%"); + Add2Columns(table, "Dictionary", "Dictionary", "Sorted listing of entries"); + Add2Columns(table, "TranslateSentence.cgi", "Translate", "Translate a sentence"); + Add2Columns(table, "Log", "Log", "Server activity log"); + Add2Columns(table, "stop.cgi", "Stop", "Stop the server"); + + strFilename = GetTempFilename(); + } + if (strName == "dictionary") + { + const wxChar cFilter = strArgs.IsEmpty() ? 'A' : toupper(strArgs[0]); + GenerateIndex(body); + + TXmlItem& table = body.AddChild("table"); + table.SetAttr("border", "1"); table.SetAttr("width", "100%"); + table.AddChild("caption").AddChild("h1") << wxString::Format("%c", cFilter); + + TXmlItem& table_th = table.AddChild("tr"); + TXmlItem& th0 = table_th.AddChild("th"); + TXmlItem& th1 = table_th.AddChild("th"); + th1 << "Original text"; + TXmlItem& th2 = table_th.AddChild("th"); + th2 << "Translated text"; + + for (size_t i = 0; i < m_DevotoOli.GetCount(); i++) + { + const wxString& orig = m_DevotoOli.OriginalEntry(i); + if (toupper(orig[0]) == cFilter) + AddEditableRow(table, orig, m_DevotoOli.TranslatedEntry(i)); + } + + strFilename = GetTempFilename(); + } + + html.Save(strFilename); +} + +void TDictionaryServer::CallCgi(wxString& strFileName) +{ + wxString strName, strExt, strArgs; + const int q = strFileName.Find('?'); + if (q > 0) + { + strArgs = strFileName.Mid(q+1); + strFileName = strFileName.Left(q); + } + wxSplitPath(strFileName, NULL, &strName, &strExt); + if (strExt == "cgi") + { + TXmlItem html; + TXmlItem& body = CreatePageBody(html); + if (strName == "EditEntry") + { + // Convert code (B-23) to position (107) + const wxChar cFirst = toupper(strArgs[0]); + const size_t nPos = atoi(strArgs.Mid(2)); + size_t nFound = 0; + for (size_t i = 0; i < m_DevotoOli.GetCount(); i++) + { + const wxChar c = toupper(m_DevotoOli.OriginalEntry(i)[0]); + if (c == cFirst) + { + if (nFound == nPos) + break; + nFound++; + } + } + + body.AddChild("h2") << "Edit Entry " << strArgs; + body.AddChild("br"); + + TXmlItem& form = body.AddChild("form"); + form.SetAttr("method", "post"); + form.SetAttr("action", "UpdateEntry.cgi"); + + form.AddChild("h3") << "Original text:"; + TXmlItem& ita = form.AddChild("textarea"); + ita.SetAttr("cols", "80"); ita.SetAttr("rows", "3"); + ita << m_DevotoOli.OriginalEntry(i); + + form.AddChild("br"); + form.AddChild("h3") << "Translated text:"; + + TXmlItem& ent = form.AddChild("input"); + ent.SetAttr("type", "hidden"); ent.SetAttr("name", "Entry"); + ent.SetAttr("value", wxString::Format("%d", i)); + + TXmlItem& eng = form.AddChild("textarea"); + eng.SetAttr("name", "Trans"); + eng.SetAttr("cols", "80"); eng.SetAttr("rows", "3"); + eng << m_DevotoOli.TranslatedEntry(i); + + form.AddChild("br"); + form.AddChild("br"); + + TXmlItem& sub = form.AddChild("input"); + sub.SetAttr("type", "submit"); + sub.SetAttr("value", "Update Translation"); + } + if (strName == "TranslateSentence") + { + body.AddChild("h3") << "Input the text to be translated:"; + + TXmlItem& form = body.AddChild("form"); + form.SetAttr("method", "post"); + form.SetAttr("action", "Translate.cgi"); + + TXmlItem& ita = form.AddChild("textarea"); + ita.SetAttr("name", "Sentence"); + ita.SetAttr("cols", "80"); ita.SetAttr("rows", "3"); + ita << "Menu Principale"; + + form.AddChild("br"); + form.AddChild("br"); + + TXmlItem& sub = form.AddChild("input"); + sub.SetAttr("type", "submit"); + sub.SetAttr("value", "Translate"); + } + strFileName = GetTempFilename(); + html.Save(strFileName); + } else + if (strExt == "exe") + { + } +} + +// Implementazione delle due funzioni pure virtuali + +const wxChar* TDictionaryServer::GetAppName() const +{ + return "Dictionary"; +} + +void TDictionaryServer::ProcessSoapCommand(wxString cmd, wxSocketBase& sock) +{ + TXmlItem xmlEnvelope; + xmlEnvelope.SetTag("SOAP-ENV:Envelope"); + TXmlItem& xmlBody = xmlEnvelope.AddChild("SOAP-ENV:Body"); + + const int soapstart = cmd.Find(" 0) + { + const size_t soaplen = cmd.length() - soapstart; + const char* buff = (const char*)cmd; + buff += soapstart; + wxMemoryInputStream input(buff, soaplen); + TXmlItem query; + if (query.Read(input)) + { + const TXmlItem* pxmlBody = query.FindFirst("SOAP-ENV:Body"); + if (pxmlBody != NULL) for (int m = 0; ; m++) + { + const TXmlItem* pxmlMethod = pxmlBody->GetChild(m); + if (pxmlMethod == NULL) + break; + if (pxmlMethod->GetTag().StartsWith("m:")) + { + wxString str = pxmlMethod->GetTag(); str += "Result"; + TXmlItem& xmlAnswer = xmlBody.AddChild(str); + SoapProcessMethod(*pxmlMethod, xmlAnswer); + } + } + } + } + const wxString strResult = xmlEnvelope.AsString(); + wxChar strLength[16]; sprintf(strLength, "%d", strResult.Length()); + + wxSocketOutputStream outs(sock); + outs << "HTTP/1.1 200 OK" << endl; + outs << "Connection: keep-alive" << endl; + outs << "Content-Length: " << strLength << endl; + outs << "Content-Type: text/xml; charset=utf-8" << endl; + outs << "Date: " << wxDateTime::Now().Format("%#c") << endl; + outs << "Server: " << GetAppName() << endl; + outs << "Host: " << wxGetHostName() << endl; + outs << endl; + outs << strResult; +} + +void TDictionaryServer::ProcessHttpGet(wxString cmd, wxSocketBase& outs) +{ + const int stop = cmd.Find(" HTTP"); + wxString str = cmd.Mid(4, stop-4).Trim(); + + if (str == "/") + str += "index.htm"; + wxString strFilename = GetDocumentRoot() + str; + + if (IsMagicName(strFilename)) + GenerateFile(strFilename); else + if (IsCgiName(strFilename)) + CallCgi(strFilename); + + SendFile(strFilename, outs); +} + +void TDictionaryServer::ProcessFormUpdateEntry(wxString& strFileName, + THashTable& hashArgs) +{ + const size_t nEntry = atoi(hashArgs.Get("Entry")); + const wxString strValue = hashArgs.Get("Trans"); + m_DevotoOli.UpdateEntry(nEntry, strValue); + strFileName = "dictionary"; + GenerateFile(strFileName); +} + +void TDictionaryServer::ProcessFormTranslate(wxString& strFileName, + THashTable& hashArgs) +{ + const wxString strValue = hashArgs.Get("Sentence"); + + TXmlItem html; + TXmlItem& body = CreatePageBody(html); + body.AddChild("h3") << "Input the text to be translated:"; + + TXmlItem& form = body.AddChild("form"); + form.SetAttr("method", "post"); + form.SetAttr("action", "Translate.cgi"); + + TXmlItem& ita = form.AddChild("textarea"); + ita.SetAttr("name", "Sentence"); + ita.SetAttr("cols", "80"); ita.SetAttr("rows", "3"); + ita << strValue; + + form.AddChild("h3") << "Translated text:"; + + const wxString strTrans = m_DevotoOli.Translate(strValue); + if (strTrans == strValue) + { + form.AddChild("p") << "Couldn't find a good translation for your text!"; + } + else + { + TXmlItem& eng = form.AddChild("textarea"); + eng.SetAttr("cols", "80"); eng.SetAttr("rows", "3"); + eng << strTrans; + } + + form.AddChild("br"); + form.AddChild("br"); + + TXmlItem& sub = form.AddChild("input"); + sub.SetAttr("type", "submit"); + sub.SetAttr("value", "Translate"); + + strFileName = GetTempFilename(); + html.Save(strFileName); +} + +void TDictionaryServer::ProcessFormCommand(wxString cmd, wxSocketBase& outs) +{ + const int stop = cmd.Find(" HTTP"); + wxString strFileName = cmd.Mid(5, stop-5).Trim(); + + wxString strName, args; + wxSplitPath(strFileName, NULL, &strName, NULL); + + const int pos = cmd.Find("\r\n\r\n"); + if (pos > 0) + args = cmd.Mid(pos+4); + + THashTable hashArgs(13); + ParseArguments(args, hashArgs); + + strFileName = GetTempFilename(); + + if (strName == "UpdateEntry") + ProcessFormUpdateEntry(strFileName, hashArgs); else + if (strName == "Translate") + ProcessFormTranslate(strFileName, hashArgs); + + SendFile(strFileName, outs); +} + +void TDictionaryServer::ProcessCommand(wxString cmd, wxSocketBase& outs) +{ + if (cmd.StartsWith("POST ")) + { + if (cmd.Find("SOAPAction") > 0) + ProcessSoapCommand(cmd, outs); + else + ProcessFormCommand(cmd, outs); + } else + if (cmd.StartsWith("GET ")) + ProcessHttpGet(cmd, outs); +} + +bool TDictionaryServer::Initialize() +{ + return m_DevotoOli.LoadIfEmpty(); +} + +bool TDictionaryServer::Deinitialize() +{ + m_DevotoOli.SaveIfNeeded(); + return true; +} + +// Istanziare l'applicazione principale + +IMPLEMENT_APP(TDictionaryServer) diff --git a/server/diction.dsp b/server/diction.dsp new file mode 100755 index 000000000..bb65c0e7b --- /dev/null +++ b/server/diction.dsp @@ -0,0 +1,209 @@ +# Microsoft Developer Studio Project File - Name="Diction" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=Diction - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "Diction.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Diction.mak" CFG="Diction - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Diction - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "Diction - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE "Diction - Win32 Debug DLL" (based on "Win32 (x86) Application") +!MESSAGE "Diction - Win32 Release DLL" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Diction - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../include" /I "../../contrib/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wx.lib xpm.lib png.lib zlib.lib jpeg.lib tiff.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /nodefaultlib:"msvcrtd.lib" /libpath:"../../lib" /libpath:"../../contrib/lib" + +!ELSEIF "$(CFG)" == "Diction - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "\wx229\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FR /FD /c +# SUBTRACT CPP /YX /Yc /Yu +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxd.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /nodefaultlib:"msvcrt.lib" /out:"../exe/servers/Diction.exe" /pdbtype:sept /libpath:"/wx229/lib" + +!ELSEIF "$(CFG)" == "Diction - Win32 Debug DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "DebugDLL" +# PROP BASE Intermediate_Dir "DebugDLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "DebugDLL" +# PROP Intermediate_Dir "DebugDLL" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../contrib/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /Yu"wx/wxprec.h" /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wx22_9d.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /out:"DebugDLL/server.exe" /pdbtype:sept /libpath:"../../lib" /libpath:"../../contrib/lib" + +!ELSEIF "$(CFG)" == "Diction - Win32 Release DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseDLL" +# PROP BASE Intermediate_Dir "ReleaseDLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseDLL" +# PROP Intermediate_Dir "ReleaseDLL" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../include" /I "../../contrib/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /FD /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wx22_9.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /out:"ReleaseDLL/server.exe" /libpath:"../../lib" /libpath:"../../contrib/lib" + +!ENDIF + +# Begin Target + +# Name "Diction - Win32 Release" +# Name "Diction - Win32 Debug" +# Name "Diction - Win32 Debug DLL" +# Name "Diction - Win32 Release DLL" +# Begin Group "Sources" + +# PROP Default_Filter "cpp" +# Begin Source File + +SOURCE=.\BaseServ.cpp +# End Source File +# Begin Source File + +SOURCE=.\Diction.cpp +# End Source File +# Begin Source File + +SOURCE=.\xml.cpp +# End Source File +# End Group +# Begin Group "Headers" + +# PROP Default_Filter "h" +# Begin Source File + +SOURCE=.\BaseServ.h +# End Source File +# Begin Source File + +SOURCE=.\Diction.h +# End Source File +# Begin Source File + +SOURCE=.\xml.h +# End Source File +# End Group +# Begin Source File + +SOURCE=.\server.rc + +!IF "$(CFG)" == "Diction - Win32 Release" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x809 /i "../../include" /i "../../contrib/include" + +!ELSEIF "$(CFG)" == "Diction - Win32 Debug" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x410 /i "c:\wx229\wx" /i /wx229/include" " + +!ELSEIF "$(CFG)" == "Diction - Win32 Debug DLL" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x809 /i "../../include" /i "../../contrib/include" + +!ELSEIF "$(CFG)" == "Diction - Win32 Release DLL" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x809 /i /wx229/include" " + +!ENDIF + +# End Source File +# End Target +# End Project diff --git a/server/diction.h b/server/diction.h index 9ebdc5176..1258535fb 100755 --- a/server/diction.h +++ b/server/diction.h @@ -1,3 +1,10 @@ +#ifndef __DICTION_H +#define __DICTION_H + +#ifndef __XML_H +#include "xml.h" +#endif + bool DoTranslate(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer); - +#endif diff --git a/server/dongle.cpp b/server/dongle.cpp new file mode 100755 index 000000000..5913918a1 --- /dev/null +++ b/server/dongle.cpp @@ -0,0 +1,933 @@ +#include "BaseServ.h" +#include "Dongle.h" + +/////////////////////////////////////////////////////////// +// TBit_array +/////////////////////////////////////////////////////////// + +TBit_array::TBit_array(size_t size) + : _bit(NULL), _size(0) +{ + if (size) + resize(index(size)); +} + +void TBit_array::copy(const TBit_array& ba) +{ + if (_bit) + { + delete _bit; + _bit = NULL; + _size = 0; + } + resize(ba._size-1); + memcpy(_bit, ba._bit, _size); +} + +TBit_array::TBit_array(const TBit_array& ba) : _bit(NULL), _size(0) +{ copy(ba); } + +TBit_array& TBit_array::operator=(const TBit_array& ba) +{ + copy(ba); + return *this; +} + +TBit_array::~TBit_array() +{ + if (_bit) + delete _bit; +} + +void TBit_array::set() +{ + if (_bit) memset(_bit, 0xFF, _size); +} + +void TBit_array::reset() +{ + if (_bit) memset(_bit, 0x0, _size); +} + +void TBit_array::resize(size_t size) +{ + size_t oldsize = _size; + unsigned long* oldbit = _bit; + + _size = size+1; + _bit = new unsigned long[_size]; + reset(); + + if (oldsize) + { + memcpy(_bit, oldbit, oldsize); + delete oldbit; + } +} + +bool TBit_array::operator[] (size_t n) const +{ + const size_t i = index(n); + if (i >= _size) return false; + return (_bit[i] & mask(n)) != 0; +} + +TBit_array& TBit_array::operator|= (const TBit_array& ba) +{ + if (_size < ba._size) + resize(ba._size); + + for (size_t i = 0; i < _size; i++) + _bit[i] |= ba._bit[i]; + + return *this; +} + +void TBit_array::set(size_t n) +{ + const size_t i = index(n); + if (i >= _size) + resize(i); + _bit[i] |= mask(n); +} + +void TBit_array::reset(size_t n) +{ + const size_t i = index(n); + if (i < _size) + _bit[i] &= ~mask(n); +} + +void TBit_array::not(size_t n) +{ + const size_t i = index(n); + if (i >= _size) resize(i); + _bit[i] ^= mask(n); +} + +size_t TBit_array::ones() const +{ + size_t one = 0; + for (size_t i = 0; i < _size; i++) + { + const unsigned long b = _bit[i]; + if (b) + { + for (unsigned long m = 1; m; m <<= 1) + if (b & m) one++; + } + } + return one; +} + +long TBit_array::last_one() const +{ + for (size_t i = _size; i--;) + { + const unsigned long b = _bit[i]; + if (b) + { + for (int j = 32; j--;) + if ((1< 0; +} + +/////////////////////////////////////////////////////////// +// Date utilities +/////////////////////////////////////////////////////////// + +wxDateTime julian2date(long julian) +{ + long x, z, m, d, y; + const long daysPer400Years = 146097L; + const long fudgedDaysPer4000Years = 1460970L + 31; + + x = julian + 68569L; + z = 4 * x / daysPer400Years; + x = x - (daysPer400Years * z + 3) / 4; + y = 4000 * (x + 1) / fudgedDaysPer4000Years; + x = x - 1461 * y / 4 + 31; + m = 80 * x / 2447; + d = x - 2447 * m / 80; + x = m / 11; + m = m + 2 - 12 * x; + y = 100 * (z - 49) + y + x; + + wxDateTime date; + date.SetYear(y); + date.SetMonth((wxDateTime::Month)m); + date.SetDay(d); + return date; +} + +long date2julian(const wxDateTime& date) +{ + const int d = date.GetDay(), m = date.GetMonth()+1, y = date.GetYear(); + + return (long)(d - 32076) + + 1461L * (y + 4800L + (m - 14) / 12) / 4 + + 367 * ( m - 2 - (m - 14) / 12 * 12) / 12 + - 3 * ((y + 4900L + (m - 14) / 12) / 100) / 4 + + 1; +} + +long date2long(const wxDateTime& date) +{ + long n = date.GetYear()*10000 + (date.GetMonth()+1)*100 + date.GetDay(); + return n; +} + +/////////////////////////////////////////////////////////// +// Utilities +/////////////////////////////////////////////////////////// + +const char* const encryption_key = "QSECOFR-"; + +wxString encode(const wxChar* data) +{ + wxString tmp; + wxChar* buf = tmp.GetWriteBuf(80); + for (int i = 0; data[i]; i++) + buf[i] = data[i] + (i < 8 ? encryption_key[i] : data[i - 8]); + buf[i] = '\0'; + tmp.UngetWriteBuf(); + return tmp; +} + +wxString decode(const char* data) +{ + wxString tmp; + wxChar* buf = tmp.GetWriteBuf(80); + for (int i = 0; data[i]; i++) + buf[i] = data[i] - (i < 8 ? encryption_key[i] : buf[i - 8]); + buf[i] = '\0'; + tmp.UngetWriteBuf(); + return tmp; +} + +/////////////////////////////////////////////////////////// +// Hardlock stuff +/////////////////////////////////////////////////////////// + +#include "hlapi_c.h" + +#define USERADR 26952 +#define AGAADR 26953 +#define PRASSIADR 26954 +#define PROCOMADR 26955 +#define REFKEY (unsigned char*)"CAMPOKEY" +#define VERKEY (unsigned char*)"ìpÙˆ¬cê<" + + +/////////////////////////////////////////////////////////// +// Smartkey stuff +/////////////////////////////////////////////////////////// + +#include "skeylink.h" +static KEY_NET* _eutron_key = NULL; + +#pragma pack(push, 1) + +struct TEutronHeader +{ + char _serno[8]; // 8 + unsigned short _year_assist; // 10 + unsigned short _max_users; // 12 + unsigned long _last_date; // 16 + unsigned long _scad_date; // 20 + unsigned long _checksum; // 24 + unsigned short _version; // 26 + unsigned short _patch; // 28 + unsigned short _offset_to_bits; // 30 + unsigned short _size_of_bits; // 32 +}; + +struct TEutronFooter +{ + unsigned long _size; // Should be sizeof(TEutronFooter) + unsigned long _checksum; // Much smarter position than header + unsigned long _filler1; + unsigned long _filler2; + unsigned long _filler3; + unsigned long _filler4; + unsigned long _filler5; + unsigned long _last_assist; // Last date of assistance query + unsigned long _assistance[MAX_DONGLE_ASSIST]; // Pre-payed assistance + + unsigned long checksum(bool set); + bool valid(); + TEutronFooter(); +}; + +#pragma pack(pop) + +TEutronFooter::TEutronFooter() +{ + const int s = sizeof(TEutronFooter); + memset(&_size, 0, s); + _size = s; +} + +unsigned long TEutronFooter::checksum(bool set) +{ + if (set) _size = sizeof(TEutronFooter); + + const unsigned short offset = sizeof(_size) + sizeof(_checksum); + unsigned char* ptr = (unsigned char*)(&_size) + offset; + const unsigned short len = unsigned short(_size - offset); + + unsigned long cs = 0; + for (unsigned short i = 0; i < len; i++, ptr++) + cs += *ptr | ~(*ptr << 8); + if (set) _checksum = cs; + return cs; +} + +bool TEutronFooter::valid() +{ + if (_size == 0 || _checksum == 0) + return false; + return _checksum == checksum(false); +} + +/////////////////////////////////////////////////////////// +// Bit helper functions +/////////////////////////////////////////////////////////// + +inline bool test_bit(unsigned short w, int b) +{ + bool on = (w & (1 << b)) != 0; + return on; +} + +inline void set_bit(unsigned short& w, int b, bool on = true) +{ + if (on) + w |= 1 << b; + else + w &= ~(1 << b); +} + +inline void reset_bit(unsigned short& w, unsigned char b) +{ + w &= ~(1 << b); +} + +/////////////////////////////////////////////////////////// +// TDongle +/////////////////////////////////////////////////////////// + +TDongle::TDongle() + : _hardware(_dongle_unknown), _type(_no_dongle), _serno(0xFFFF), + _dirty(false), _max_users(1), _year_assist(2002) +{ + memset(_eprom, 0, sizeof(_eprom)); +} + +TDongle::~TDongle() +{ + if (_serno != 0xFFFF) + Logout(); +} + +// Data punta ad un array di 4 words +// Deve essere cosi' per problemi del C, +// non trasformare in array: pena di morte! +void TDongle::garble(unsigned short* data) const +{ + switch (_hardware) + { + case _dongle_hardlock: + HL_CODE(data, 1); + break; + case _dongle_eutron: + if (_eutron_key) + { + _eutron_key->net_command = NET_KEY_ACCESS; + _eutron_key->command = SCRAMBLING_MODE; + memcpy(_eutron_key->data, data, 8); + smartlink(_eutron_key); + if (_eutron_key->status == ST_OK) + memcpy(data, _eutron_key->data, 8); + } + break; + default: + break; + } +} + +bool TDongle::already_programmed() const +{ +/* + if (_hardware == _dongle_hardlock) + { + unsigned short data[4]; + memcpy(data, &_eprom[60], sizeof(data)); + garble(data); + + if (data[0] < 1997 || data[0] > 2997) + return false; + + if (data[1] == 0 || data[1] >= 10000) + return false; + + const TDate today(TODAY); + const long& giulio = (const long&)data[2]; + const long yyyymmdd = today.julian2date(giulio); + const TDate d(yyyymmdd); + if (d.year() < 1997 || d > today) + return false; + } else + if (_hardware == _dongle_eutron) + { + const TEutronHeader* eh = (const TEutronHeader*)_eprom; + if (eh->_serno[0] == 0 || eh->_checksum == 0) + return false; // Really virgin. + + unsigned long cs = 0; + for (byte* ptr = (byte*)_eprom; ptr < (byte*)&eh->_checksum; ptr++) + cs += *ptr | ~(*ptr << 8); + if (eh->_checksum != cs) + return false; // Malicious programming! + } +*/ + return true; +} + +bool TDongle::hardlock_login(bool test_all_keys) +{ + bool ok = true; + _type = _user_dongle; + if (test_all_keys) + { + HL_LOGOUT(); + if (HL_LOGIN(AGAADR, LOCAL_DEVICE, REFKEY, VERKEY) == STATUS_OK) + _type = _aga_dongle; + else + { + HL_LOGOUT(); + if (HL_LOGIN(PRASSIADR, LOCAL_DEVICE, REFKEY, VERKEY) == STATUS_OK) + _type = _prassi_dongle; + else + { + HL_LOGOUT(); + if (HL_LOGIN(PROCOMADR, LOCAL_DEVICE, REFKEY, VERKEY) == STATUS_OK) + _type = _procom_dongle; + } + } + } + HL_LOGOUT(); + ok = HL_LOGIN(USERADR, DONT_CARE, REFKEY, VERKEY) == STATUS_OK; + + if (ok) + { + _hardware = _dongle_hardlock; + + HL_READBL((unsigned char*)_eprom); + + unsigned short data[4]; + memcpy(data, _eprom, sizeof(data)); + garble(data); + + if (data[0] == 0xFAE8) + _serno = data[1]; + else + { + if (data[0] == 0x3283 || data[0] == 0xA3AA) // chiave programmatori !! + { + if (_type == _user_dongle) + _type = _developer_dongle; + _serno = 0; + } + } + } + + if (ok) + { + _max_users = 1; + _last_update = wxDateTime::Now(); + _year_assist = _last_update.GetYear(); + + if (_type == _user_dongle) + { + const bool already = already_programmed(); + + _module.reset(); // Disattiva tutti i moduli + const int last_word = already ? 12 : 4; + unsigned short data[4]; + + // Legge flag di attivazione dei moduli + for (int i = 0; i < last_word; i += 4) + { + memcpy(data, &_eprom[48+i], sizeof(data)); + garble(data); + if (data[3] == _serno) // Validate block + { + for (int j = 0; j < 3; j++) + { + unsigned short parola = data[j] ^ _serno; + if (parola) + { + for (int b = 15; b >= 0; b--) + { + if (test_bit(parola, b)) + { + const unsigned short bit = i * 12 + j * 16 + b; + _module.set(bit+1); + } + } + } + } + } + else + break; + } + _module.set(0, true); // Forza l'attivazione della base + + // Legge anno di assitenza e numero massimo di utenti + memcpy(data, &_eprom[60], sizeof(data)); + garble(data); + + if (already) + { + _year_assist = data[0]; + _max_users = data[1]; + const long& giulio = (const long&)data[2]; + _last_update = julian2date(giulio); + } + else + { + _year_assist = 0; + _dirty = true; + } + } + else + { + _module.set(255); // Last module on key + _module.set(); // Activate all modules + + _max_users = 4; + _last_update = wxDateTime::Now(); + _year_assist = _last_update.GetYear(); + } + } + else + _type = _no_dongle; + + return ok; +} + +bool TDongle::eutron_login(bool test_all_keys) +{ + bool ok = false; + + if (_eutron_key == NULL) + _eutron_key = new KEY_NET; + memset(_eutron_key, 0, sizeof(KEY_NET)); + _eutron_key->net_command = NET_KEY_OPEN; + // _eutron_key->command = LOCATING_MODE; + _eutron_key->status = ST_HW_FAILURE; // Don't leave ST_OK = 0 here! + + const char* labels[5] = { "AGA.INFORMATICA", "AGA.PRASSI", "AGA.PROCOM", + "AGA.CAMPO", "25EBAI" }; + TDongleType types[5] = { _aga_dongle, _prassi_dongle, _procom_dongle, + _user_dongle, _developer_dongle }; + for (int k = test_all_keys ? 0 : 3; k < 5; k++) + { + memset(_eutron_key->label, 0, LABEL_LENGTH); + memcpy(_eutron_key->label, labels[k], strlen(labels[k])); + memset(_eutron_key->password, 0, PASSWORD_LENGTH); + memcpy(_eutron_key->password, ::encode(labels[k]), strlen(labels[k])); + + smartlink(_eutron_key); + ok = _eutron_key->status == ST_OK; + if (ok) + { + _hardware = _dongle_eutron; + _type = types[k]; + break; + } + } + if (ok) + { + _serno = 0; + _max_users = 1; + _last_update = wxDateTime::Now(); + _year_assist = _last_update.GetYear(); + + if (_type == _user_dongle) + { + _module.reset(); // Disattiva tutti i moduli + if (read_words(0, sizeof(TEutronHeader) / 2, _eprom)) + { + const TEutronHeader* eh = (const TEutronHeader*)_eprom; + wxString serno = eh->_serno; serno.Truncate(8); + _serno = unsigned(atol(serno)); + if (already_programmed()) + { + _max_users = eh->_max_users; + _last_update = eh->_last_date; + _year_assist = eh->_year_assist; + + // Calcola il numero della word dove cominciano i bit di attivazione + unsigned short otb = eh->_offset_to_bits; + if (otb == 0) otb = 16; // Compatibile Hardlock + + unsigned short sob = eh->_size_of_bits; + if (sob == 0) sob = 16; // Compatibile Hardlock + + unsigned short data[64]; + if (read_words(otb, sob, data)) + { + int module = 1; + for (unsigned short w = 0; w < sob; w++) + { + for (int b = 0; b < 16; b++) + { + if (test_bit(data[w], b)) + _module.set(module); + module++; + } + } + } + } + else + _dirty = true; + } + _module.set(0, true); // Forza l'attivazione della base + } + else + { + _max_users = 4; + _module.set(255); // Last module on key + _module.set(); // Activate all modules + } + } + else + { + delete _eutron_key; + _eutron_key = NULL; + } + return ok; +} + +bool TDongle::Login(bool test_all_keys) +{ + bool ok = true; + + if (_type != _no_dongle) // Already logged in + Logout(); + + TDongleHardware hw = _hardware; + if (hw == _dongle_unknown) + hw = (TDongleHardware)GetServerApp().GetConfigInt("Donglehw"); + switch(hw) + { + case _dongle_hardlock: + ok = hardlock_login(test_all_keys); + break; + case _dongle_eutron: + ok = eutron_login(test_all_keys); + break; + default: + ok = false; + break; + } + if (!ok) + { + if (!ok && hw != _dongle_eutron) + ok = eutron_login(test_all_keys); + if (!ok && hw != _dongle_hardlock) + ok = hardlock_login(test_all_keys); + if (ok) + GetServerApp().SetConfigInt("Donglehw",(int)_hardware); + } + return ok; +} + +bool TDongle::Logout() +{ + if (_type != _no_dongle) + { + switch (_hardware) + { + case _dongle_hardlock: + HL_LOGOUT(); + break; + case _dongle_eutron: + if (_eutron_key) + { + _eutron_key->net_command = NET_KEY_CLOSE; + _eutron_key->command = 0; + smartlink(_eutron_key); + } + break; + default: + break; + } + } + + _type = _no_dongle; + _serno = 0xFFFF; + + return true; +} + +bool TDongle::Connected() +{ + bool ok = false; + if (type() != _no_dongle) + { + unsigned short a[4] = { 0, 0, 0, 0 }; + garble(a); + for (int i = 0; i < 4; i++) + ok |= (a[0] != 0); + } + return ok; +} + +// Data punta ad un array di 4 words +// Deve essere cosi' per problemi del C, +// non trasformare in array: pena di morte! +bool TDongle::read_words(unsigned short reg, unsigned short len, unsigned short* ud) const +{ + bool ok = false; + switch (_hardware) + { + case _dongle_hardlock: + { + for (unsigned short i = 0; i < len; i++) + HL_READ(reg+i, &ud[i]); + ok = true; + } + break; + case _dongle_eutron: + if (_eutron_key) + { + _eutron_key->net_command = NET_KEY_ACCESS; + _eutron_key->command = BLOCK_READING_MODE; + unsigned short* pointer = (unsigned short*)(&_eutron_key->data[0]); + unsigned short* number = (unsigned short*)(&_eutron_key->data[2]); + while (len > 0) + { + *pointer = reg; + *number = (len <= 16) ? len : 16; + smartlink(_eutron_key); + + ok = _eutron_key->status == ST_OK; + if (ok) + memcpy(ud, &_eutron_key->data[4], (*number)*2); + else + { + GetServerApp().WriteLog("*** EUTRON read error"); + break; + } + len -= *number; + reg += *number; + ud += *number; + } + } + break; + default: + break; + } + return ok; +} + +// Data punta ad un array di 4 words +// Deve essere cosi' per problemi del C, +// non trasformare in array: pena di morte! +bool TDongle::write_words(unsigned short reg, unsigned short len, unsigned short* data) const +{ + bool ok = false; + switch(_hardware) + { + case _dongle_hardlock: + { + int err = STATUS_OK; + for (unsigned short r = 0; r < len; r++) + { + const unsigned short address = reg+r; + err = HL_WRITE(address, data[r]); + if (err != STATUS_OK) + { + GetServerApp().WriteLog("*** HARDLOCK write error"); + break; + } + } + ok = err == STATUS_OK; + } + break; + case _dongle_eutron: + if (_eutron_key) + { + _eutron_key->net_command = NET_KEY_ACCESS; + _eutron_key->command = BLOCK_WRITING_MODE; + unsigned short* pointer = (unsigned short*)(&_eutron_key->data[0]); + unsigned short* number = (unsigned short*)(&_eutron_key->data[2]); + while (len > 0) + { + *pointer = reg; + *number = len > 16 ? 16 : len; + memcpy(&_eutron_key->data[4], data, (*number)*2); + smartlink(_eutron_key); + ok = _eutron_key->status == ST_OK; + if (!ok) + { + GetServerApp().WriteLog("*** EUTRON write error"); + break; + } + reg += *number; + len -= *number; + data += *number; + } + } + default: + break; + } + return ok; +} + +bool TDongle::burn_hardlock() +{ + unsigned short data[4]; + + const wxDateTime today = wxDateTime::Now(); + const bool already = already_programmed(); + if (already) + { + memcpy(data, &_eprom[60], sizeof(data)); + garble(data); + if (data[0] < 1997 || data[0] > 2997) + { + GetServerApp().WriteLog("On Line Assistance error."); + return false; + } + if (data[1] == 0 || data[1] >= 10000) + { + GetServerApp().WriteLog("*** Bad users number."); + return false; + } + const long& val = (const long&)data[2]; + const wxDateTime date= julian2date(val); + if (date > today) + { + GetServerApp().WriteLog("*** Too late sir: key has already expired!"); + return false; + } + } + + data[0] = _year_assist; + data[1] = _max_users; + long& val = (long&)data[2]; + val = date2julian(today); + garble(data); + write_words(60, 4, data); + _last_update = today; + + // Il primo bit della memoria della chiave corrisponde al modulo uno + // non allo zero (che e' la base ed e' sempre attivo) + unsigned short module = 1; + for (int octect = 0; octect < 3; octect++) + { + for(int parola = 0; parola < 3; parola++) + { + unsigned short& p = data[parola]; + p = 0; + for (int bit = 0; bit < 16; bit++) + { + if (Active(module)) + set_bit(p, bit); + module++; + } + p ^= _serno; + } + data[3] = _serno; + garble(data); + write_words(48 + 4*octect, 4, data); + } + + return true; +} + +bool TDongle::burn_eutron() +{ + TEutronHeader* eh = (TEutronHeader*)_eprom; + memset(eh, 0, sizeof(TEutronHeader)); + + _last_update = wxDateTime::Now(); + sprintf(eh->_serno, "%lu", (unsigned long)_serno); + eh->_year_assist = _year_assist; + eh->_max_users = _max_users; + eh->_last_date = date2long(_last_update); + eh->_scad_date = 0; + + unsigned long cs = 0; + for (unsigned char* ptr = (unsigned char*)_eprom; ptr < (unsigned char*)&eh->_checksum; ptr++) + cs += *ptr | ~(*ptr << 8); + eh->_checksum = cs; + + const unsigned short otb = sizeof(TEutronHeader) / 2; + const unsigned short sob = 16; + eh->_offset_to_bits = otb; + eh->_size_of_bits = sob; + + bool ok = write_words(0, otb, _eprom); + + if (ok) + { + unsigned short data[sob]; memset(data, 0, sizeof(data)); + for (int module = 1; module < 256; module++) + { + if (Active(module)) + { + unsigned short& w = data[(module-1) / 16]; + set_bit(w, (module-1) % 16, true); + } + } + ok = write_words(otb, sob, data); + } + + return ok; +} + +bool TDongle::Burn() +{ + bool ok = _type == _user_dongle; + + if (ok) + { + switch(_hardware) + { + case _dongle_hardlock: ok = burn_hardlock(); break; + case _dongle_eutron : ok = burn_eutron(); break; + default : break; + } + } + if (ok) + _dirty = false; + + return ok; +} + diff --git a/server/dongle.h b/server/dongle.h new file mode 100755 index 000000000..869e2157b --- /dev/null +++ b/server/dongle.h @@ -0,0 +1,113 @@ +#ifndef __DONGLE_H +#define __DONGLE_H + +#ifndef _WX_DATETIME_H +#include +#endif + +enum TDongleHardware { _dongle_unknown, _dongle_hardlock, _dongle_eutron }; +enum TDongleType { _no_dongle, _user_dongle, _developer_dongle, _aga_dongle, _prassi_dongle, _procom_dongle }; +enum { MAX_DONGLE_ASSIST = 8 }; + +class TBit_array : public wxObject +{ + size_t _size; + unsigned long* _bit; + +protected: + virtual bool ok() const; + + void resize(size_t size); + void copy(const TBit_array& ba); + size_t index(size_t n) const + { return size_t(n >> 5); } + unsigned long mask(size_t n) const + { return unsigned long(1 << (n & 0x1F)); } + +public: + TBit_array(size_t size = 0); + TBit_array(const TBit_array& ba); + virtual ~TBit_array(); + + TBit_array& operator=(const TBit_array& ba); + bool operator[] (size_t n) const; + TBit_array& operator |=(const TBit_array& b); + + size_t items() const { return 8L * _size; } + long first_one() const; + long last_one() const; + size_t ones() const; + + void set(size_t n); + void reset(size_t n); + void not(size_t n); + + void set(size_t n, bool on) { on ? set(n) : reset(n); } + void set(); + void reset(); +}; + +class TDongle : public wxObject +{ + TDongleHardware _hardware; + TDongleType _type; + + wxString _admin, _admpwd; + + unsigned short _serno, _max_users, _year_assist; + unsigned short _eprom[64]; + wxDateTime _last_update; + TBit_array _module; + bool _dirty; + +protected: + bool already_programmed() const; + + bool hardlock_login(bool test_all_dongles); + bool eutron_login(bool test_all_dongles); + + bool burn_hardlock(); + bool burn_eutron(); + +public: + bool Ok() const + { return _hardware != _dongle_unknown && + _type != _no_dongle && + _serno != 0xFFFF; } + +public: + bool Login(bool test_all_dongles = false); + bool Logout(); + bool Connected(); + + unsigned short Number() const { return _serno; } + unsigned short MaxUsers() const { return _max_users; } + unsigned short YearAssist() const { return _year_assist; } + + void garble(unsigned short* data) const; + + // Solo per un po' di tempo, poi diverranno protected (servono a ba1500 old style) + bool read_words(unsigned short reg, unsigned short len, unsigned short *data) const; + bool write_words(unsigned short reg, unsigned short len, unsigned short *data) const; + + TDongleType type() const { return _type; } + + bool Active(size_t module) const { return _module[module]; } + void Activate(size_t module, bool on = TRUE) { _module.set(module, on); _dirty = TRUE; } + void Deactivate(size_t module) { Activate(module, FALSE); } + void set_max_users(unsigned short u) { _max_users = u; _dirty = TRUE; } + void set_year_assist(unsigned short y) { _year_assist = y; _dirty = TRUE; } + const wxDateTime& last_update() const { return _last_update; } + + bool dirty() const { return _dirty; } + bool Burn(); + + TDongleHardware hardware() const { return _hardware; } + + TDongle(); + virtual ~TDongle(); +}; + +long date2julian(const wxDateTime& date); + +#endif diff --git a/server/example.cpp b/server/example.cpp new file mode 100755 index 000000000..807946b4f --- /dev/null +++ b/server/example.cpp @@ -0,0 +1,29 @@ +#include "BaseServ.h" + +class MyServer : public TBaseServerApp +{ +protected: + virtual const wxChar* GetAppName() const; + virtual void ProcessCommand(wxString cmd, wxSocketOutputStream& outs); +}; + +// Implementare almeno queste due funzioni pure virtuali + +const wxChar* MyServer::GetAppName() const +{ + return "MyServer"; +} + +void MyServer::ProcessCommand(wxString cmd, wxSocketOutputStream& outs) +{ + WriteLog("Processing..."); + outs << "\n" + << "

Hello world!

\n" + << "

Http command:

\n" + << "

" << cmd << "

\n" + << "\n"; +} + +// Istanziare l'applicazione principale + +IMPLEMENT_APP(MyServer) diff --git a/server/fastapi.h b/server/fastapi.h new file mode 100755 index 000000000..f395ad156 --- /dev/null +++ b/server/fastapi.h @@ -0,0 +1,651 @@ +/****************************************************************************/ +/** **/ +/** Hardlock **/ +/** API-Structures and definitions **/ +/** **/ +/** This file contains some helpful defines to access a Hardlock using **/ +/** the application programming interface (API) for Hardlock. **/ +/** **/ +/** Aladdin Germany **/ +/** **/ +/** Revision history **/ +/** ---------------- +*** $Log: not supported by cvs2svn $ +*** Revision 1.1.2.1 2002/10/16 10:45:22 guy +*** Patch level : 2.0 +*** Files correlati : servers +*** Ricompilazione Demo : [ ] +*** Commento : +*** Creata una camionata di servers +*** +*** Revision 1.1.2.1 2002/05/30 13:42:20 guy +*** Patch level : 2.0 nopatch +*** Files correlati : fastapi.h +*** Ricompilazione Demo : [ ] +*** Commento : +*** Sarà d'uopo includere anch'esso, va là! +*** +*** Revision 1.46 2000/12/19 16:37:41 chris +*** detect MacOS X +*** +*** Revision 1.45 2000/07/30 22:22:17 chris +*** ia64 detection +*** +*** Revision 1.44 2000/07/10 09:45:09 chris +*** Module2 field +*** +*** Revision 1.43 2000/05/25 14:11:43 chris +*** added some HASP stuff +*** +*** Revision 1.42 2000/03/21 14:18:28 chris +*** HL_SIS and HL_LIS structure definitions +*** +*** Revision 1.41 2000/02/18 14:04:44 chris +*** fixed pascal define for CygWin & MingW32 +*** +*** Revision 1.40 1999/12/06 13:06:11 chris +*** fixed structure packing for MSC compiler +*** +*** Revision 1.39 1999/11/28 01:39:46 chris +*** added 64bit support (only tested with AlphaLinux currently) +*** +*** Revision 1.38 1999/10/07 11:28:45 chris +*** Duplicate revision +*** +*** Revision 1.37 1999/10/07 11:28:45 Henri +*** Removed uneeded TLV defines. +*** +*** Revision 1.36 1999/10/07 10:47:04 Henri +*** Removed unused flags. +*** +*** Revision 1.35 1999/09/30 09:27:46 Henri +*** Added PORT_BUSY. +*** +*** Revision 1.34 1999/09/24 07:49:43 Werner +*** Added RUS_RTB_EXPIRED and RUS_SERIAL_MISMATCH +*** error codes. +*** +*** Revision 1.33 1999/09/21 12:06:57 Henri +*** Arranged error codes. +*** +*** Revision 1.32 1999/09/20 12:56:28 Werner +*** Added FORCE_ALF_CREATE constant. +*** +*** Revision 1.31 1999/09/15 17:04:18 Henri +*** Changed WriteLicense. +*** +*** Revision 1.30 1999/09/01 15:06:44 Adi +*** Added special handling of global expiration date. +*** +*** Revision 1.29 1999/08/16 13:03:58 chris +*** restore previous structure packing after HL_API definition +*** (for MSVC) +*** +*** Revision 1.28 1999/08/08 23:10:55 chris +*** added 2 bytes to reserved field: API structure was 2 bytes too short +*** +*** Revision 1.27 1999/08/04 13:04:41 chris +*** API_FFS_GETRUSINFO define +*** +*** Revision 1.26 1999/08/04 11:03:33 chris +*** API_FFS_WRITE_LIC definition and some more status codes +*** +*** Revision 1.25 1999/08/03 20:36:15 chris +*** renamed FIB structure to RUS_FIB to avoid clash +*** with api_defs.h +*** +*** Revision 1.24 1999/07/26 10:58:28 Henri +*** Added FIB structure. +*** +*** Revision 1.23 1999/07/19 10:29:35 Henri +*** Renamed define for BUFFER_TOO_SMALL +*** +*** Revision 1.22 1999/07/19 10:11:30 Henri +*** Added RUS functionality. +*** +*** Revision 1.21 1998/10/21 15:56:53 Henri +*** Changed defines for Borland Builder. +*** +*** Revision 1.20 1998/08/14 11:33:54 Henri +*** Changed driver comment. +*** +*** Revision 1.19 1998/07/10 12:34:05 Henri +*** Added define for Borland Builder. +*** +*** Revision 1.18 1998/06/29 09:01:36 Henri +*** Extended API struc. +*** +*** Revision 1.17 1998/06/08 16:36:31 chris +*** fixed structure packing on gcc version 2.7 and above +*** +*** Revision 1.16 1998/05/08 14:11:33 Henri +*** Added defines for HL_READID. +*** +*** Revision 1.15 1998/04/07 13:14:59 chris +*** added API_READ_ID function code +*** +*** Revision 1.14 1998/02/17 21:56:19 Henri +*** Added pragma pack(1) for Watcom 11/DOS +*** +*** Revision 1.13 1997/07/01 13:56:54 henri +*** Fixed defines for LabView. +*** +*** Revision 1.12 1997/04/28 15:30:53 chris +*** define UNIX32 ifdef __QNX__ +*** +*** Revision 1.11 1997/02/03 18:08:36 henri +*** Renamed error 17 +*** +*** Revision 1.10 1997/01/30 17:16:55 henri +*** Added LM return codes. +*** +*** Revision 1.9 1997/01/28 08:23:30 henri +*** Missed a semicolon ;-) +*** +*** Revision 1.8 1997/01/27 17:57:11 henri +*** Added slot number in API structure. +*** +*** Revision 1.7 1997/01/16 18:18:11 henri +*** Added API_LMINIT function code. +*** +*** Revision 1.6 1996/11/13 16:55:49 chris +*** added SOLARIS & UNIX32 define +*** +*** Revision 1.5 1996/08/12 16:23:43 henri +*** Added VCS log. +*** +**/ +/****************************************************************************/ + +#if !defined(_FASTAPI_H_) +#define _FASTAPI_H_ + +#if defined(LINUX) || defined(SOLARIS) || defined(SCO) || defined(__QNX__) || defined(DARWIN) || defined(MACOSX) + #define UNIX32 + #if defined(__alpha__) || defined(__ia64__) + #ifndef __64BIT__ + #define __64BIT__ + #endif + #define NO_UNALIGN + #endif +#endif + +#ifdef __OS2__ + #ifdef INTERNAL_16BITDLL + #define LOAD_DS + #else + #ifdef __WATCOMC__ + #ifdef __386__ /* not the 16bit compiler */ + #include + #endif + #else + #include + #endif + #endif + #ifdef OS_16 + #define RET_ Word + #define FAR_ far pascal + #define DATAFAR_ far + #else + #define RET_ APIRET + #define FAR_ + #define CALL_ APIENTRY + #define DATAFAR_ + #endif + #pragma pack(2) +#endif + +#ifdef UNIX32 + #define __386__ + #define pascal + #pragma pack(1) +#endif + +#ifdef __GNUC__ + #define __386__ + #if !defined(__CYGWIN__) && !defined(__MINGW32__) + #define pascal + #endif + #if ((__GNUC__==2) && (__GNUC_MINOR__>=7)) || (__GNUC__>2) + #define ALIGN_GCC __attribute__ ((__packed__)) + #ifdef NO_UNALIGN + #define AS_ALIGN __attribute__ ((__aligned__(8))) + #endif + #else + #pragma pack(1) + #endif +#endif + +#ifdef _MSC_VER +#if _MSC_VER >= 900 + #pragma pack(push,_fastapi_h_,1) +#else + #pragma pack(1) +#endif +#endif + +#if defined(WINNT) || defined(__WIN32__) || defined(_WIN32) + #ifndef __386__ /* Watcom doesnt like it */ + #define __386__ + #endif + #ifdef DLL + #define CALL_ __stdcall + #else + #define CALL_ + #endif +#endif + +#ifdef DOS386 /* Symantec C */ + #define __386__ + #pragma pack(2) +#endif + +#ifdef __HIGHC__ /* Metaware High C */ + #define __386__ + #define _PACKED _Packed +#endif + +#ifdef __ZTC__ /* Zortech C */ + #define __386__ +#endif + +#ifdef SALFORD /* Salford C */ + #define ALIGN_ 8 +#endif + +#ifdef __WATCOMC__ + #pragma pack(1) + #ifndef __386__ + #ifndef OS_16 + #define CALL_ cdecl + #endif + #endif +#endif + +#ifdef _CVI_ /* LabWindows/CVI */ + #define RET_ Word + #ifndef _NI_mswin32_ + #define CALL_ pascal + #else /* No pascal in WIN32-Version of LabWindows/CVI 4.0.1 */ + #define CALL_ _stdcall + #endif + #ifndef __386__ /* __386__ defined by LabWindows/CVI */ + #define FAR_ far + #define DATAFAR_ far + #endif +#endif + +#ifdef __386__ + #define DATAFAR_ + #define FAR_ +#endif + +#ifdef HLHIGH_DLL + #define CALL_ pascal _export +#endif + +#ifdef LOAD_DS + #define CALL_ _loadds +#endif + +#ifndef CALL_ + #define CALL_ +#endif + +#ifndef _PACKED + #define _PACKED +#endif + +#ifndef ALIGN_GCC +# define ALIGN_GCC +#endif + +#ifndef DATAFAR_ + #define DATAFAR_ far +#endif + +#ifndef FAR_ + #define FAR_ far +#endif + +#ifndef RET_ + #define RET_ Word +#endif + +#ifndef ALIGN_ + #define ALIGN_ +#endif + +#ifndef AS_ALIGN + #define AS_ALIGN +#endif + +/* -------------------------------- */ +/* Definitions and API structures : */ +/* -------------------------------- */ +#ifdef __64BIT__ +typedef unsigned int Long; +typedef unsigned long Int64; +#else +typedef unsigned long Long; +#endif +#ifndef __BCPLUSPLUS__ + typedef unsigned char Byte; + typedef unsigned short Word; +#else + #ifndef VCL_H + typedef unsigned char Byte; + typedef unsigned short Word; + #endif +#endif +#ifndef __64BIT__ +#define set_data_ptr(api,buf) (api)->Data=(Byte DATAFAR_ *)(buf) +#define get_data_ptr(api) ((void *)((api)->Data)) +#else /* above macros for <=32 bit, below macros for >32 bit */ +#define set_data_ptr(api,buf) do { (api)->Data=(((Long)(buf)) & 0xffffffffu); \ + (api)->DataHigh=(((Long)(((Int64)(buf))>>32)) \ + & 0xffffffffu);} while (0) +#define get_data_ptr(api) ((void *)((Int64)((api)->Data) | \ + (((Int64)((api)->DataHigh))<<32))) +#endif + +typedef struct + { + Word Use_Key; + Byte Key[8]; + } ALIGN_GCC DES_MODE; + +typedef struct + { + Word ModAd; /* Hardlock module address */ + Word Reg; /* Memory register adress */ + Word Value; /* Memory value */ + Byte Reserved[4]; + } ALIGN_GCC EYE_MODE; + +typedef struct + { + Long PW1; /* HASP passwords */ + Long PW2; + Word P1; + } ALIGN_GCC HASP_MODE; + +typedef struct + { + Word LT_Reserved; + Word Reg; /* Memory register adress */ + Word Value; /* Memory value */ + Word Password[2]; /* Access passwords */ + } ALIGN_GCC LT_MODE; + +typedef union + { + DES_MODE Des; + EYE_MODE Eye; + LT_MODE Lt; + HASP_MODE Hasp; + } HARDWARE; + +typedef struct + { + Word P2; + Word P3; + } ALIGN_GCC HASP_MODE2; + +typedef union + { + HASP_MODE2 Hasp2; + } HARDWARE2; + +typedef struct rus_fib + { + Byte MARKER[2]; + Long SERIAL_ID; + Byte VERSION[2]; + Word FIXED; + Word VAR; + Word CRC; + } ALIGN_GCC RUS_FIB; + +typedef _PACKED struct ALIGN_ hl_api + { + Byte API_Version_ID[2]; /* Version */ + Word API_Options[2]; /* API Optionflags */ + Word ModID; /* Modul-ID (EYE = 0...) */ + HARDWARE Module; /* Hardware type */ + +#ifdef __OS2__ /* Pointer to cipher data */ + #ifdef OS_16 + void far *Data; + #else + #ifdef __BORLANDC__ + void FAR16PTR Data; + #else + void * _Seg16 Data; + #endif + #endif +#else + #ifndef __64BIT__ + void DATAFAR_ *Data; + #else + Long Data; /* low part only */ + #endif +#endif + + Word Bcnt; /* Number of blocks */ + Word Function; /* Function number */ + Word Status; /* Actual status */ + Word Remote; /* Remote or local?? */ + Word Port; /* Port address if local */ + Word Speed; /* Speed of port if local */ + Word NetUsers; /* Current Logins (HL-Server) */ + Byte ID_Ref[8]; /* Referencestring */ + Byte ID_Verify[8]; /* Encrypted ID_Ref */ + Long Task_ID; /* Multitasking program ID */ + Word MaxUsers; /* Maximum Logins (HL-Server) */ + Long Timeout; /* Login Timeout in minutes */ + Word ShortLife; /* (multiple use) */ + Word Application; /* Application number */ + Word Protocol; /* Protocol flags */ + Word PM_Host; /* DOS Extender type */ + Long OSspecific; /* ptr to OS specific data */ + Word PortMask; /* Default local search (in) */ + Word PortFlags; /* Default local search (out) */ + Word EnvMask; /* Use env string search (in) */ + Word EnvFlags; /* Use env string search (out) */ + Byte EEFlags; /* EE type flags */ + Word Prot4Info; /* (internal use) */ + Byte FuncOptions; /* Enable add. functionality */ + Word Slot_ID; /* Licence slot number */ + Word Slot_ID_HIGH; /* Licence slot High value */ + Word RUS_ExpDate; /* RUS Expiration date */ + Long DataHigh; /* Pointer to data high value */ +#ifndef __64BIT__ + void DATAFAR_ *VendorKey; /* Pointer to RUS vendor key */ +#else + Long VendorKey; /* dto. */ +#endif + Long VendorKeyHigh; /* Vendor key high value */ + Long OSspecificHigh; /* ptr to OS specific data */ + Long RUS_MaxInfo; /* RUS max user/counter */ + Long RUS_CurInfo; /* RUS current user/counter */ + RUS_FIB RUS_Fib; /* RUS FIB structure */ + HARDWARE2 Module2; /* 2nd hw dependend fields */ + Byte Reserved2[122]; /* Reserved area */ + } ALIGN_GCC AS_ALIGN HL_API, LT_API, HS_API; + +typedef _PACKED struct ALIGN_ { /* HL_LIS slot information */ + Long max_user; + Long cur_user; + Word exp_date; + Byte flag; /* singularity flag */ + Byte res; /* filler to make structure size multiple of 4 bytes */ +} ALIGN_GCC HL_SIS; + +/* License Information Structure (HL_LIS) */ +typedef _PACKED struct ALIGN_ { + Word current_date; + Word res; + Long num_slots; + Word glob_exp_date; + Word res2; /* filler to make size multiple of 4 bytes */ + HL_SIS slots[1]; +} ALIGN_GCC HL_LIS; + +#ifdef UNIX32 + #pragma pack() +#endif + +#ifdef __OS2__ + #pragma pack() +#endif + +#ifdef _MSC_VER +#if _MSC_VER >= 900 + #pragma pack(pop,_fastapi_h_) +#else + #pragma pack() +#endif +#endif + + +/* ------------- */ +/* Module-ID's : */ +/* ------------- */ +#define EYE_DONGLE 0 /* Hardlock E-Y-E */ +#define DES_DONGLE 1 /* FAST DES */ +#define LT_DONGLE 3 /* Hardlock LT */ +#define HASP_DONGLE 4 /* HASP */ + +/* --------------------- */ +/* API function calls : */ +/* --------------------- */ +#define API_INIT 0 /* Init API structure */ +#define API_DOWN 1 /* Free API structure */ +#define API_FORCE_DOWN 31 /* Force deinintialization */ +#define API_MULTI_SHELL_ON 2 /* MTS is enabled */ +#define API_MULTI_SHELL_OFF 3 /* MTS is disabled */ +#define API_MULTI_ON 4 /* Enable MTS */ +#define API_MULTI_OFF 5 /* Disable MTS */ +#define API_AVAIL 6 /* Dongle available? */ +#define API_LOGIN 7 /* Login dongle server */ +#define API_LOGOUT 8 /* Logout dongle server */ +#define API_INFO 9 /* Get API informations */ +#define API_GET_TASKID 32 /* Get TaskID from API */ +#define API_LOGIN_INFO 34 /* Get API Login informations */ + +/* --------------------------- */ +/* Data and memory functions : */ +/* --------------------------- */ +#define API_KEYE 11 /* Use KEYE for encryption */ +#define API_READ 20 /* Read one word of dongle EEPROM */ +#define API_WRITE 21 /* Write one word of dongle EEPROM */ +#define API_READ_BLOCK 23 /* Read EEPROM in one block */ +#define API_WRITE_BLOCK 24 /* Write EEPROM in one block */ +#define API_READ_ID 29 /* Read USB ID memory */ +#define API_ABORT 51 /* Critical Error Abort */ + +/* -------------- */ +/* LM functions : */ +/* -------------- */ +#define API_LMINIT 40 /* LM compatible API_INIT replacement */ +#define API_LMPING 41 /* checks if LM dongle and slot is available */ +#define API_LMINFO 42 /* info about currently used LIMA */ + +/* --------------- */ +/* RUS functions : */ +/* --------------- */ +#define API_FFS_INIT 256 /* RUS init function, downed with API_DOWN */ +#define API_FFS_ISRUSHL 257 /* Is RUS HL ? */ +#define API_FFS_LOGIN 258 /* RUS Login to Hardlock server */ +#define API_FFS_CHECK_LIC 259 /* RUS Create LIS */ +#define API_FFS_READ_LICBLOCK 260 /* RUS Read LIC Block */ +#define API_FFS_QUERY_SLOT 261 /* RUS query slot function */ +#define API_FFS_FREE_SLOT 262 /* RUS free slot */ +#define API_FFS_OCCUPY_SLOT 263 /* RUS occupies a slot */ +#define API_FFS_INC_CNTR 264 /* RUS counter increment */ +#define API_FFS_PARSERTB 265 /* RUS Parse RTB */ +#define API_FFS_GET_HWDEP_INFO 266 /* RUS get hardware dependent information */ +#define API_FFS_WRITE_LIC 267 /* RUS write updated license information */ +#define API_FFS_GETRUSINFO 269 /* get RUS info */ + +/* -------------------- */ +/* Dongle access mode : */ +/* -------------------- */ +#define LOCAL_DEVICE 1 /* Query local HL only */ +#define NET_DEVICE 2 /* Query remote HL only */ +#define DONT_CARE 3 /* Query local or remote HL */ + +/* -------------------- */ +/* EnvMask/Port Flags : */ +/* -------------------- */ +#define USB_DEVICE 256 /* Port flag for USB use */ +#define IGNORE_ENVIRONMENT 0x8000 /* Ignore HL_SEARCH */ +#define EEF_NOAUTOUSB 8 /* No automatic USB search */ + +/* ---------- */ +/* RUS flags: */ +/* ---------- */ +#define FORCE_RUS 1 /* Enable RUS init without VK */ +#define FORCE_ALF_CREATE 1 /* Force creation of ALF file in HLM_WRITELICENSE */ + +/* ------------------ */ +/* API PM_Host ID's : */ +/* ------------------ */ +#define API_XTD_DETECT 0 +#define API_XTD_DPMI 1 /* QDPMI, Borland, Windows ... */ +#define API_XTD_PHAR386 2 +#define API_XTD_PHAR286 3 +#define API_XTD_CODEBLDR 4 /* Intel Code Builder */ +#define API_XTD_COBOLXM 5 + +/* ------------------ */ +/* API Status Codes : */ +/* ------------------ */ +#define STATUS_OK 0 /* API call was succesfull */ +#define NOT_INIT 1 /* DONGLE not initialized */ +#define ALREADY_INIT 2 /* Already initialized */ +#define UNKNOWN_DONGLE 3 /* Device not supported */ +#define UNKNOWN_FUNCTION 4 /* Function not supported */ +#define HLS_FULL 6 /* HL-Server login table full */ +#define NO_DONGLE 7 /* No device available */ +#define NETWORK_ERROR 8 /* A network error occured */ +#define NO_ACCESS 9 /* No device available */ +#define INVALID_PARAM 10 /* A wrong parameter occured */ +#define VERSION_MISMATCH 11 /* HL-Server not API version */ +#define DOS_ALLOC_ERROR 12 /* Error on memory allocation */ +#define CANNOT_OPEN_DRIVER 14 /* Can not open Hardlock driver */ +#define INVALID_ENV 15 /* Invalid environment string */ +#define DYNALINK_FAILED 16 /* Unable to get a function entry */ +#define INVALID_LIC 17 /* No valid licence info (LM) */ +#define NO_LICENSE 18 /* Slot/licence not enabled (LM) */ +#define PORT_BUSY 19 /* Cannot acquire port */ +#define RUS_NO_DEVICE 20 /* Key is no Hardlock RUS key */ +#define RUS_INVALID_LIC 21 /* Invalid RUS license */ +#define RUS_SYNC_ERR 22 /* FIB in key and api struc mismatch */ +#define NOT_IMPLEMENTED 23 /* not (yet) implemented */ +#define BUFFER_TOO_SMALL 24 /* Buffer for function too small */ +#define UNKNOWN_HW_TYPE 25 /* unknown hardware descriptor */ +#define RUS_INV_FBPOS 26 /* unknown fixed block position */ +#define RUS_INVALID_SLOT 27 /* Non-existing slot number given */ +#define RUS_DATE_FAKE 28 /* RUS Date fake detected */ +#define RUS_COUNT_DOWN 29 /* RUS dead counter limit reached */ +#define RUS_INVALID_VK 30 /* RUS Vendor key is invalid */ +#define RUS_NO_LIC_FILE 31 /* RUS License file not found */ +#define RUS_INV_VBLOCK 32 /* RUS invalid variable block */ +#define RUS_LIC_FILE_WRITE_ERR 33 /* error writing (updated) license file */ +#define RUS_NO_INFO_AVAILABLE 34 /* GET_HWDEP_INFO: no info there */ +#define RUS_INFO_PACK_ERR 35 /* " " " " : cannot TLV encode data */ +#define RUS_LIC_WRITE_ERR 36 /* write license failed */ +#define RUS_DATE_EXPIRED 37 /* RUS Expiration Date reached. */ +#define TS_DETECTED 38 /* Term. Server / Citrix Winframe detected*/ +#define RUS_INVALID_RTB 39 /* Invalid updated data (RTB) */ +#define RUS_RTB_EXPIRED 40 /* Update data (RTB) has expired. */ +#define RUS_SERIAL_MISMATCH 41 /* Update data serial does not match */ +#define TOO_MANY_USERS 256 /* Login table full (remote) */ +#define SELECT_DOWN 257 /* Printer not On-line */ +#define NO_SERIALID 258 /* Serial ID not readable or n/a */ + +#endif /*_FASTAPI_H_*/ +/* eof */ + diff --git a/server/hlapi_c.h b/server/hlapi_c.h new file mode 100755 index 000000000..7f5a1b175 --- /dev/null +++ b/server/hlapi_c.h @@ -0,0 +1,72 @@ +/* $Id: hlapi_c.h,v 1.2 2002-10-24 10:47:33 alex Exp $ */ + +#include "fastapi.h" + +/* --------------------- */ +/* Function prototypes : */ +/* --------------------- */ +#ifdef __cplusplus + extern "C" { +#endif + +/* ------------------ */ +/* Basic Hardlock API */ +/* ------------------ */ +RET_ FAR_ CALL_ HL_LOGIN (Word ModAd, Word Access, Byte DATAFAR_ *RefKey, Byte DATAFAR_ *VerKey); +RET_ FAR_ CALL_ HL_LOGOUT (void); +RET_ FAR_ CALL_ HL_AVAIL (void); +RET_ FAR_ CALL_ HL_PORTINF (void); +RET_ FAR_ CALL_ HL_ACCINF (void); +RET_ FAR_ CALL_ HL_USERINF (void); +RET_ FAR_ CALL_ HL_MAXUSER (void); +RET_ FAR_ CALL_ HL_MEMINF (void); +RET_ FAR_ CALL_ HL_CODE (void DATAFAR_ *Data, Word Count); +RET_ FAR_ CALL_ HL_WRITE (Word Reg, Word Value); +RET_ FAR_ CALL_ HL_READ (Word Reg, Word DATAFAR_ *Value); +RET_ FAR_ CALL_ HL_READBL (Byte DATAFAR_ *Eeprom); +RET_ FAR_ CALL_ HL_WRITEBL (Byte DATAFAR_ *Eeprom); +RET_ FAR_ CALL_ HL_ABORT (void); +RET_ FAR_ CALL_ HL_VERSION (void); +RET_ FAR_ CALL_ HL_HLSVERS (void); +RET_ FAR_ CALL_ HL_SELECT (HL_API DATAFAR_ *hl_ptr); +RET_ FAR_ CALL_ HL_READID (Word DATAFAR_ *IDLow, Word DATAFAR_ *IDHigh); + +/* ---------------- */ +/* Hardlock RUS API */ +/* ---------------- */ +RET_ FAR_ CALL_ HLM_LOGIN (Word ModAd, Word Access, Byte DATAFAR_ *RefKey, Byte DATAFAR_ *VerKey, Byte DATAFAR_ * VKey, Long RUSOptions, Byte DATAFAR_ * SearchStr); +RET_ FAR_ CALL_ HLM_OCCUPYSLOT (Long Slot); +RET_ FAR_ CALL_ HLM_FREESLOT (Long Slot); +RET_ FAR_ CALL_ HLM_CHECKSLOT (Long Slot, Long * MaxUser, Long * CurrentUser); +RET_ FAR_ CALL_ HLM_CHECKCOUNTER (Word IncVal, Long * MaxCounter, Long * CurrentCounter); +RET_ FAR_ CALL_ HLM_CHECKEXPDATE (Long Slot, Word * Year, Word * Month, Word * Day); +RET_ FAR_ CALL_ HLM_GETRUSINFO (Long * BufLen, Byte DATAFAR_ * RTBBuffer, Word Base64); +RET_ FAR_ CALL_ HLM_WRITELICENSE (Long BufLen, Byte DATAFAR_ * RTBBuffer, Word Access, Byte DATAFAR_ * SearchStr,Word Options); +RET_ FAR_ CALL_ HLM_ISRUSHL (Long * ID); +RET_ FAR_ CALL_ HLM_CHECKALLSLOTS (Long *BufLen, HL_LIS *Buffer); +RET_ FAR_ CALL_ HLM_LOGOUT (void); + +/* ---------------------- */ +/* Hardlock Error Routine */ +/* ---------------------- */ +const char * FAR_ CALL_ HL_ERRMSG (Word num, Long options, Byte ** errdefine, Byte ** errextmsg); + +/* ------------------------------------------- */ +/* Obsolete functions, for compatiblity only!! */ +/* ------------------------------------------- */ +#ifndef __OS2__ +void FAR_ CALL_ HL_ON (Word Port, Word ModAd); +void FAR_ CALL_ HL_OFF (Word Port); +Word FAR_ CALL_ K_EYE (Word Port, char DATAFAR_ *Inp, Word BlkCnt); +void FAR_ CALL_ HL_WR (Word Port, Word Reg, Word Val); +Word FAR_ CALL_ HL_RD (Word Port, Word Reg); +void FAR_ CALL_ INT_ON (void); +void FAR_ CALL_ INT_OFF (void); +#endif +RET_ FAR_ CALL_ HL_CALC (Word i1, Word i2, Word i3, Word i4); +RET_ FAR_ CALL_ HL_LMLOGIN (Word ModAd, Word Access, Byte DATAFAR_ *RefKey, Byte DATAFAR_ *VerKey, Word SlotID, Byte DATAFAR_ *SearchStr); + +#ifdef __cplusplus + }; +#endif +/* eof */ diff --git a/server/lerch.cpp b/server/lerch.cpp new file mode 100755 index 000000000..4e14c71e7 --- /dev/null +++ b/server/lerch.cpp @@ -0,0 +1,247 @@ +#include "BaseServ.h" + +#include +#include + +#include + +class TLerchServer : public TBaseServerApp +{ +protected: + virtual const wxChar* GetAppName() const; + virtual void ProcessCommand(wxString cmd, wxSocketBase& outs); + +public: + void GenerateFile(wxString& strFilename); + bool IsMagicName(wxString& strFilename) const; + bool IsCgiName(wxString strFilename) const; + void CreateServersList(wxArrayString& arr) const; + void ProcessHttpGet(wxString cmd, wxSocketBase& outs); + + void ProcessFormStart(const THashTable& args, wxSocketBase& sock); + void ProcessFormKill(const THashTable& args, wxSocketBase& sock); + void CallCgi(wxString& strFileName, wxSocketBase& sock); +}; + +const wxChar* TLerchServer::GetAppName() const +{ + return "Lerch"; +} + +void TLerchServer::CreateServersList(wxArrayString& arr) const +{ + wxFileInputStream ini(GetConfigName()); + const size_t size = ini.GetSize(); + wxChar* buff = new wxChar[size]; + ini.Read(buff, size); + + const char* aperta = strchr(buff, '['); + while (aperta != NULL) + { + char* chiusa = strchr(aperta+1, ']'); + if (chiusa != NULL) + { + *chiusa = '\0'; + wxString str = aperta+1; + if (str != GetAppName()) + arr.Add(str); + aperta = strchr(chiusa+1, '['); + } + else + break; + } + + delete buff; +} + +void TLerchServer::GenerateFile(wxString& strFilename) +{ + TXmlItem html; + TXmlItem& body = CreatePageBody(html); + + if (strFilename == "index") + { + TXmlItem& table = body.AddChild("table"); + table.SetAttr("border", "1"); table.SetAttr("width", "100%"); + strFilename = GetTempFilename(); + + wxArrayString arr; CreateServersList(arr); + for (size_t i = 0; i < arr.GetCount(); i++) + { + wxIniConfig ini("", "", GetConfigName()); + wxString str; + str << '/' << arr[i]; + ini.SetPath(str); + + wxString strHost; + ini.Read("Host", &strHost, wxGetHostName()); + + int nPort; + ini.Read("Port", &nPort, 3883); + + wxString strIcon; + ini.Read("Icon", &strIcon, "euro.gif"); + + int nRunning; + ini.Read("Running", &nRunning, 0); + + TXmlItem& tr = table.AddChild("tr"); + TXmlItem& td0 = tr.AddChild("td"); + td0.SetAttr("width", "15%"); td0.SetAttr("align", "center"); + TXmlItem& a = td0.AddChild("a"); + a.SetAttr("href", wxString::Format("http://%s:%d/index.htm", strHost, nPort)); + TXmlItem& img = a.AddChild("img"); + img.SetAttr("src", strIcon); img.SetAttr("border", 0); img.SetAttr("alt", arr[i]); + + TXmlItem& td1 = tr.AddChild("td"); td1.SetAttr("width", "15%"); + TXmlItem& form = td1.AddChild("center").AddChild("form"); + form.SetAttr("action", nRunning ? "kill.cgi" : "start.cgi"); + + TXmlItem& name = form.AddChild("input"); + name.SetAttr("type", "hidden"); name.SetAttr("name", "App"); + name.SetAttr("value", arr[i]); + + TXmlItem& submit = form.AddChild("input"); + submit.SetAttr("type", "submit"); + submit.SetAttr("value", nRunning ? "Stop" : "Start"); + + tr.AddChild("td") << arr[i] << " Server"; + } + + html.Save(strFilename); + } +} + +bool TLerchServer::IsMagicName(wxString& strFilename) const +{ + wxString strName; + wxSplitPath(strFilename, NULL, &strName, NULL); + strName.MakeLower(); + if (strName == "index") + { + strFilename = strName; + return true; + } + if (strName == "log") + { + strFilename = GetLogFileName(); + } + + return false; +} + +bool TLerchServer::IsCgiName(wxString strFilename) const +{ + const int q = strFilename.Find('?'); + if (q > 0) + strFilename.Truncate(q); + + wxString strExt; + wxSplitPath(strFilename, NULL, NULL, &strExt); + strExt.MakeLower(); + return strExt == "cgi" || strExt == "exe"; +} + +void TLerchServer::ProcessFormStart(const THashTable& args, wxSocketBase& sock) +{ + const wxString strApp = args.Get("App"); + const wxString strRun = GetConfigString("Run", "", strApp); + if (wxFileExists(strRun)) + { + wxExecute(strRun); + for (int i = 0; i < 3; i++) + { + wxSleep(3); + if (GetConfigInt("Running", 0, strApp) == 1) + break; + } + wxString strFileName = "index"; + GenerateFile(strFileName); + SendFile(strFileName, sock); + } + else + MessageBox("ERROR", wxString::Format("Can't run %s", strRun), sock); +} + +void TLerchServer::ProcessFormKill(const THashTable& args, wxSocketBase& sock) +{ + const wxString strApp = args.Get("App"); + const wxString strHost = GetConfigString("Host", "localhost", strApp); + const int nPort = GetConfigInt("Port", 0, strApp); + if (nPort > 0) + { + wxIPV4address addr; + addr.Hostname(strHost); + addr.Service(nPort); + + wxSocketClient sock; + if (sock.Connect(addr)) + { + const wxString str = "GET /stop.cgi HTTP/1.1\r\n\r\n"; + for (int i = 0; i < 3; i++) + { + sock.Write(str, str.Length()); + wxSleep(1); + if (GetConfigInt("Running", 0, strApp) == 0) + break; + } + } + + SetConfigString("Running", "0", strApp); + } + wxString strFileName = "index"; + GenerateFile(strFileName); + SendFile(strFileName, sock); +} + +void TLerchServer::CallCgi(wxString& strFileName, wxSocketBase& sock) +{ + wxString strName, strExt, strArgs; + const int q = strFileName.Find('?'); + if (q > 0) + { + strArgs = strFileName.Mid(q+1); + strFileName.Truncate(q); + } + wxSplitPath(strFileName, NULL, &strName, &strExt); + + THashTable hashArgs(13); + ParseArguments(strArgs, hashArgs); + + if (strExt == "cgi") + { + if (strName == "start") + ProcessFormStart(hashArgs, sock); else + if (strName == "kill") + ProcessFormKill(hashArgs, sock); + } +} + +void TLerchServer::ProcessHttpGet(wxString cmd, wxSocketBase& outs) +{ + const int stop = cmd.Find(" HTTP"); + wxString str = cmd.Mid(4, stop-4).Trim(); + + if (str == "/") + str += "index.htm"; + wxString strFilename = GetDocumentRoot() + str; + + if (IsCgiName(strFilename)) + CallCgi(strFilename, outs); + else + { + if (IsMagicName(strFilename)) + GenerateFile(strFilename); + SendFile(strFilename, outs); + } +} + +void TLerchServer::ProcessCommand(wxString cmd, wxSocketBase& outs) +{ + if (cmd.StartsWith("GET ")) + ProcessHttpGet(cmd, outs); +} + +// Istanziare l'applicazione principale + +IMPLEMENT_APP(TLerchServer) diff --git a/server/lerch.dsp b/server/lerch.dsp new file mode 100755 index 000000000..c6b1c0412 --- /dev/null +++ b/server/lerch.dsp @@ -0,0 +1,209 @@ +# Microsoft Developer Studio Project File - Name="Lerch" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=Lerch - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "Lerch.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Lerch.mak" CFG="Lerch - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Lerch - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "Lerch - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE "Lerch - Win32 Debug DLL" (based on "Win32 (x86) Application") +!MESSAGE "Lerch - Win32 Release DLL" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Lerch - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../include" /I "../../contrib/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wx.lib xpm.lib png.lib zlib.lib jpeg.lib tiff.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /nodefaultlib:"msvcrtd.lib" /libpath:"../../lib" /libpath:"../../contrib/lib" + +!ELSEIF "$(CFG)" == "Lerch - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "\wx229\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FR /FD /c +# SUBTRACT CPP /YX /Yc /Yu +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxd.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /nodefaultlib:"msvcrt.lib" /out:"../exe/servers/Lerch.exe" /pdbtype:sept /libpath:"/wx229/lib" + +!ELSEIF "$(CFG)" == "Lerch - Win32 Debug DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "DebugDLL" +# PROP BASE Intermediate_Dir "DebugDLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "DebugDLL" +# PROP Intermediate_Dir "DebugDLL" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../contrib/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /Yu"wx/wxprec.h" /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wx22_9d.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /out:"DebugDLL/server.exe" /pdbtype:sept /libpath:"../../lib" /libpath:"../../contrib/lib" + +!ELSEIF "$(CFG)" == "Lerch - Win32 Release DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseDLL" +# PROP BASE Intermediate_Dir "ReleaseDLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseDLL" +# PROP Intermediate_Dir "ReleaseDLL" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../include" /I "../../contrib/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /FD /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wx22_9.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /out:"ReleaseDLL/server.exe" /libpath:"../../lib" /libpath:"../../contrib/lib" + +!ENDIF + +# Begin Target + +# Name "Lerch - Win32 Release" +# Name "Lerch - Win32 Debug" +# Name "Lerch - Win32 Debug DLL" +# Name "Lerch - Win32 Release DLL" +# Begin Group "Sources" + +# PROP Default_Filter "cpp" +# Begin Source File + +SOURCE=.\BaseServ.cpp +# End Source File +# Begin Source File + +SOURCE=.\Lerch.cpp +# End Source File +# Begin Source File + +SOURCE=.\xml.cpp +# End Source File +# End Group +# Begin Group "Headers" + +# PROP Default_Filter "h" +# Begin Source File + +SOURCE=.\BaseServ.h +# End Source File +# Begin Source File + +SOURCE=.\Lerch.h +# End Source File +# Begin Source File + +SOURCE=.\xml.h +# End Source File +# End Group +# Begin Source File + +SOURCE=.\server.rc + +!IF "$(CFG)" == "Lerch - Win32 Release" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x809 /i "../../include" /i "../../contrib/include" + +!ELSEIF "$(CFG)" == "Lerch - Win32 Debug" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x410 /i "c:\wx229\wx" /i /wx229/include" " + +!ELSEIF "$(CFG)" == "Lerch - Win32 Debug DLL" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x809 /i "../../include" /i "../../contrib/include" + +!ELSEIF "$(CFG)" == "Lerch - Win32 Release DLL" + +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x809 /i /wx229/include" " + +!ENDIF + +# End Source File +# End Target +# End Project diff --git a/server/lerch.h b/server/lerch.h new file mode 100755 index 000000000..1258535fb --- /dev/null +++ b/server/lerch.h @@ -0,0 +1,10 @@ +#ifndef __DICTION_H +#define __DICTION_H + +#ifndef __XML_H +#include "xml.h" +#endif + +bool DoTranslate(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer); + +#endif diff --git a/server/server.cpp b/server/server.cpp index 33ee2971f..dabd676b9 100755 --- a/server/server.cpp +++ b/server/server.cpp @@ -18,11 +18,12 @@ #include #include +#include "wx/wfstream.h" #include #include - +#include "http.h" #include "soap.h" // -------------------------------------------------------------------------- @@ -32,206 +33,50 @@ // Define a new application type class SoapServerApp : public wxApp { + wxEvtHandler* m_server; + public: virtual bool OnInit(); + virtual int OnExit(); }; -// Define a new frame type: this is going to be our main frame -class SoapFrame : public wxFrame +enum { - clock_t m_last_text; + SERVER_ID = 1001, + SOCKET_ID = 1002 +}; -public: - SoapFrame(); - ~SoapFrame(); +class SoapServer : public wxEvtHandler +{ + wxSocketServer* m_server; + wxFileOutputStream* m_log; - // event handlers (these functions should _not_ be virtual) - - void OnQuit(wxCommandEvent& event); - void OnAbout(wxCommandEvent& event); - void OnServerEvent(wxSocketEvent& event); - void OnSocketEvent(wxSocketEvent& event); - - // Roba mia - void AppendText(const wxChar* str); - int GetDefaultPort() const; +protected: + int GetDefaultPort() const; + void AppendText(const char* str); void ProcessSoapCommand(wxSocketBase *sock); - // convenience functions - void UpdateStatusBar(); +public: + bool Ok() const { return m_server->Ok(); } + SoapServer(); + ~SoapServer(); -private: - wxSocketServer *m_server; - wxTextCtrl *m_text; - wxMenu *m_menuFile; - wxMenuBar *m_menuBar; - bool m_busy; - int m_numClients; - - // any class wishing to process wxWindows events must use this macro - DECLARE_EVENT_TABLE() + void OnServerEvent(wxSocketEvent& event); + void OnSocketEvent(wxSocketEvent& event); + DECLARE_EVENT_TABLE(); }; -// -------------------------------------------------------------------------- -// constants -// -------------------------------------------------------------------------- - -// IDs for the controls and the menu commands -enum -{ - // menu items - SERVER_QUIT = 1000, - SERVER_ABOUT, - - // id for sockets - SERVER_ID, - SOCKET_ID -}; - -// -------------------------------------------------------------------------- -// event tables and other macros for wxWindows -// -------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(SoapFrame, wxFrame) - EVT_MENU(SERVER_QUIT, SoapFrame::OnQuit) - EVT_MENU(SERVER_ABOUT, SoapFrame::OnAbout) - EVT_SOCKET(SERVER_ID, SoapFrame::OnServerEvent) - EVT_SOCKET(SOCKET_ID, SoapFrame::OnSocketEvent) +BEGIN_EVENT_TABLE(SoapServer, wxEvtHandler) + EVT_SOCKET(SERVER_ID, SoapServer::OnServerEvent) + EVT_SOCKET(SOCKET_ID, SoapServer::OnSocketEvent) END_EVENT_TABLE() -IMPLEMENT_APP(SoapServerApp) - - -// ========================================================================== -// implementation -// ========================================================================== - -// -------------------------------------------------------------------------- -// the application class -// -------------------------------------------------------------------------- - -bool SoapServerApp::OnInit() +void SoapServer::AppendText(const char* str) { - // Create the main application window - SoapFrame *frame = new SoapFrame(); - - // Show it and tell the application that it's our main window - frame->Show(TRUE); - SetTopWindow(frame); - - // Success - return TRUE; + *m_log << str << "\r\n"; } -// -------------------------------------------------------------------------- -// main frame -// -------------------------------------------------------------------------- - -int SoapFrame::GetDefaultPort() const -{ - int nPort = 3883; - wxIniConfig ini("", "", "./campo.ini"); - ini.SetPath("/Server"); - const wxString str = ini.Read("Dictionary", ""); - const int colon = str.Find(':'); - if (colon > 0) - nPort = atoi(str.Mid(colon+1)); - return nPort; -} - -void SoapFrame::AppendText(const wxChar* str) -{ - const clock_t now = clock(); - if (now - m_last_text > 60000) - m_text->SetValue(str); - else - m_text->AppendText(str); - m_last_text = now; -} - -// frame constructor - -SoapFrame::SoapFrame() : wxFrame((wxFrame *)NULL, -1, "Soap Server", - wxDefaultPosition, wxSize(300, 300)) -{ - // Give the frame an icon - SetIcon(wxICON(mondrian)); - - // Make menus - m_menuFile = new wxMenu(); - m_menuFile->Append(SERVER_ABOUT, "&About...\tCtrl-A", "Show about dialog"); - m_menuFile->AppendSeparator(); - m_menuFile->Append(SERVER_QUIT, "E&xit\tAlt-X", "Quit server"); - - // Append menus to the menubar - m_menuBar = new wxMenuBar(); - m_menuBar->Append(m_menuFile, "&File"); - SetMenuBar(m_menuBar); - - // Make a textctrl for logging - m_text = new wxTextCtrl(this, -1, - "Welcome to SOAP Server\n", - wxDefaultPosition, wxDefaultSize, - wxTE_MULTILINE | wxTE_READONLY); - - // Status bar - CreateStatusBar(2); - - // Create the address - defaults to localhost:0 initially - wxIPV4address addr; - addr.Service(GetDefaultPort()); - - // Create the socket - m_server = new wxSocketServer(addr); - m_last_text = clock(); - - // We use Ok() here to see if the server is really listening - if (! m_server->Ok()) - { - wxString str; - str << "Could not listen to port " << addr.Service() << "\n\n"; - AppendText(str); - return; - } - else - { - wxString str; - str << "Server listening on port " << addr.Service() << "\n\n"; - AppendText(str); - } - - // Setup the event handler and subscribe to connection events - m_server->SetEventHandler(*this, SERVER_ID); - m_server->SetNotify(wxSOCKET_CONNECTION_FLAG); - m_server->Notify(TRUE); - - m_busy = FALSE; - m_numClients = 0; - UpdateStatusBar(); -} - -SoapFrame::~SoapFrame() -{ - // No delayed deletion here, as the frame is dying anyway - delete m_server; -} - -// event handlers - -void SoapFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) -{ - // TRUE is to force the frame to close - Close(TRUE); -} - -void SoapFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) -{ - wxMessageBox("Soap Server\n(c) 2002 by Aga\n", - "About Soap Server", - wxOK | wxICON_INFORMATION, this); -} - -void SoapFrame::ProcessSoapCommand(wxSocketBase *sock) +void SoapServer::ProcessSoapCommand(wxSocketBase *sock) { sock->SetFlags(wxSOCKET_NOWAIT); @@ -240,24 +85,29 @@ void SoapFrame::ProcessSoapCommand(wxSocketBase *sock) unsigned int len = sock->Read(buf, sizeof(buf)).LastCount(); AppendText(buf); - wxString strAnswer = SoapProcessMessage(buf, len); - - AppendText("\n\n"); - AppendText(strAnswer); - - // Write it back - sock->Write(strAnswer, strAnswer.Length()); + wxString str; + if (strncmp(buf, "POST", 4) == 0) + { + wxString strAnswer = SoapProcessMessage(buf, len); + sock->Write(strAnswer, strAnswer.Length()); + AppendText(strAnswer); + } else + if (strncmp(buf, "GET ", 4) == 0) + { + str = buf; + HttpProcessMessage(str, sock, *m_log); + } } -void SoapFrame::OnServerEvent(wxSocketEvent& event) + +void SoapServer::OnServerEvent(wxSocketEvent& event) { wxString s = "OnServerEvent: "; - wxSocketBase *sock; switch(event.GetSocketEvent()) { - case wxSOCKET_CONNECTION : s.Append("wxSOCKET_CONNECTION\n"); break; - default : s.Append("Unexpected event !\n"); break; + case wxSOCKET_CONNECTION : s.Append("wxSOCKET_CONNECTION"); break; + default : s.Append("Unexpected event!"); break; } AppendText(s); @@ -267,15 +117,14 @@ void SoapFrame::OnServerEvent(wxSocketEvent& event) // non-blocking accept (although if we got here, there // should ALWAYS be a pending connection). - sock = m_server->Accept(FALSE); - + wxSocketBase* sock = m_server->Accept(FALSE); if (sock) { - AppendText("New client connection accepted\n\n"); + AppendText("New client connection accepted"); } else { - AppendText("Error: couldn't accept a new connection\n\n"); + AppendText("Error: couldn't accept a new connection"); sock->Destroy(); return; } @@ -283,12 +132,9 @@ void SoapFrame::OnServerEvent(wxSocketEvent& event) sock->SetEventHandler(*this, SOCKET_ID); sock->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG); sock->Notify(TRUE); - - m_numClients++; - UpdateStatusBar(); } -void SoapFrame::OnSocketEvent(wxSocketEvent& event) +void SoapServer::OnSocketEvent(wxSocketEvent& event) { wxString s = "OnSocketEvent: "; wxSocketBase *sock = event.GetSocket(); @@ -320,8 +166,6 @@ void SoapFrame::OnSocketEvent(wxSocketEvent& event) } case wxSOCKET_LOST: { - m_numClients--; - // Destroy() should be used instead of delete wherever possible, // due to the fact that wxSocket uses 'delayed events' (see the // documentation for wxPostEvent) and we don't want an event to @@ -331,21 +175,72 @@ void SoapFrame::OnSocketEvent(wxSocketEvent& event) // middle of a test or something. Destroy() takes care of all // this for us. - AppendText("Deleting socket.\n\n"); + AppendText("Deleting socket."); sock->Destroy(); break; } default: ; } - - UpdateStatusBar(); } -// convenience functions - -void SoapFrame::UpdateStatusBar() +int SoapServer::GetDefaultPort() const { - wxString s; - s.Printf("%d clients connected", m_numClients); - SetStatusText(s, 1); + int nPort = 3883; + wxIniConfig ini("", "", "./campo.ini"); + ini.SetPath("/Server"); + const wxString str = ini.Read("Dictionary", ""); + const int colon = str.Find(':'); + if (colon > 0) + nPort = atoi(str.Mid(colon+1)); + return nPort; +} + +SoapServer::SoapServer() +{ + // Create the address - defaults to localhost:0 initially + wxIPV4address addr; + addr.Service(GetDefaultPort()); + + // Create the socket + m_server = new wxSocketServer(addr); + + m_log = new wxFileOutputStream("soaplog.txt"); + + wxString str; + + // We use Ok() here to see if the server is really listening + if (m_server->Ok()) + { + // Setup the event handler and subscribe to connection events + m_server->SetEventHandler(*this, SERVER_ID); + m_server->SetNotify(wxSOCKET_CONNECTION_FLAG); + m_server->Notify(TRUE); + + str << "Server listening on port " << addr.Service(); + } + else + { + str << "Could not listen to port " << addr.Service(); + } + AppendText(str); +} + +SoapServer::~SoapServer() +{ + delete m_server; + delete m_log; +} + +IMPLEMENT_APP(SoapServerApp) + +bool SoapServerApp::OnInit() +{ + m_server = new SoapServer; + return TRUE; +} + +int SoapServerApp::OnExit() +{ + delete m_server; + return wxApp::OnExit(); } diff --git a/server/skeylink.h b/server/skeylink.h new file mode 100755 index 000000000..6e79fc035 --- /dev/null +++ b/server/skeylink.h @@ -0,0 +1,181 @@ +#ifndef __SKEYLINK_H +#define __SKEYLINK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __SKEYDRV_H +#define __SKEYDRV_H + +/* + Smartkey commands +*/ +#define MAKE_KEY_CODE(low,high) (((unsigned short)(low)) | (((unsigned short)(high)) << 8)) + +#define SCRAMBLING_MODE 's' +#define READING_MODE 'r' +#define WRITING_MODE 'w' +#define FIXING_MODE 'f' +#define LOCATING_MODE 'l' +#define COMPARING_MODE 'c' +#define PROGRAMMING_MODE 'p' +#define MODEL_READING_MODE 'm' +#define ENCRYPTING_MODE 'e' +#define BLOCK_READING_MODE MAKE_KEY_CODE('b','r') +#define BLOCK_WRITING_MODE MAKE_KEY_CODE('b','w') + +/* + Smartkey NEW commands +*/ +#define SERIAL_NUMBER_READING_MODE 'n' +#define FIX_READING_MODE 'x' +#define EXT_MODEL_READING_MODE 'h' +#define FAIL_COUNTER_READING_MODE 'a' + +/* + Legacy commands +*/ +#define DEACTIVATE_ACCESS_MODE MAKE_KEY_CODE('d','d') +#define ACTIVATE_ACCESS_MODE MAKE_KEY_CODE('d','a') +#define ANTIHACKER_MODE 't' + +/* + Smartkey models +*/ +#define SKEY_NONE '0' /* No Smartkey */ +#define SKEY_FX '1' /* Smartkey mod. FX */ +#define SKEY_PR '2' /* Smartkey mod. PR */ +#define SKEY_EP '3' /* Smartkey mod. EP */ +#define SKEY_NET_5 '4' /* Smartkey mod. NET 5 users */ +#define SKEY_NET_10 '5' /* Smartkey mod. NET 10 users */ +#define SKEY_NET_25 '6' /* Smartkey mod. NET 25 users */ +#define SKEY_NET_50 '7' /* Smartkey mod. NET 50 users */ +#define SKEY_NET_NL '8' /* Smartkey mod. NET no limit */ +#define SKEY_SP '9' /* Smartkey mod. SP */ +#define SKEY_NET 'A' /* Smartkey mod. NET */ +#define SKEY_SB 'B' /* Smartkey mod. SB */ +#define SKEY_WI 'C' /* Smartkey mod. WI */ + +/* + Return codes +*/ +#define ST_OK 0 /* No errors */ +#define ST_NONE_KEY -1 /* No Smartkey present */ +#define ST_SYNT_ERR -2 /* Syntax error */ +#define ST_LABEL_FAILED -3 /* Uncorrect label */ +#define ST_PW_DATA_FAILED -4 /* Uncorrect password or data */ +#define ST_EXEC_ERROR -16 /* Max exec reached */ +#define ST_HW_FAILURE -20 /* Smartkey damaged */ + +/* + Field length +*/ +#define LABEL_LENGTH 16 +#define PASSWORD_LENGTH 16 +#define DATA_LENGTH 64 +#define EXTENDED_DATA_LENGTH 352 +#define SCRAMBLE_LENGTH 8 + +/* + Communication structure definition +*/ +#pragma pack(push,1) + +typedef struct __SKEY_DATA { + short lpt; + short command; + unsigned char label[LABEL_LENGTH]; + unsigned char password[PASSWORD_LENGTH]; + unsigned char data[DATA_LENGTH]; + short fail_counter; + short status; + unsigned char ext_data[EXTENDED_DATA_LENGTH]; +} SKEY_DATA; + +#pragma pack(pop) + +#endif /* __SKEYDRV_H */ + +/* + Smartkey net command codes +*/ +#define NET_KEY_OPEN 'O' +#define NET_KEY_ACCESS 'A' +#define NET_KEY_CLOSE 'C' + +/* + Smartkey command codes +*/ +#define USER_NUMBER_MODE 'U' + +/* + Net return codes +*/ +#define ST_NET_ERROR -5 /* Lan error */ +#define ST_CLOSE_ERROR -6 /* Attempting to CLOSE without OPENing */ +#define ST_ACCESS_ERROR -7 /* Attempting to ACCESS without OPENing */ +#define ST_USER_ERROR -8 /* Max user reached */ +#define ST_NET_PWD_ERR -9 /* Net password wrong */ +#define ST_TSR_NOT_INST -10 /* SKEYSRV not found */ +#define ST_INIT_ERROR -11 /* Insufficient PC memory */ +#define ST_PATH_ERR -12 /* Path error of file not found */ +#define ST_DRIVER_NOT_INST -13 /* SKEYTSR not installed */ +#define ST_TOO_MANY_OPEN_KEY -14 /* Too many open SmartKey */ +#define ST_NET_PASS_INVALID -15 /* Invalid net password */ + +#define ST_NET_CONF_ERROR -21 /* Configuration error in INI/Registry/Environment */ +#define ST_NET_ANP_INIT_ERROR -22 /* Error inizializing the ANP protocol */ +#define ST_NET_TCPIP_INIT_ERROR -23 /* Error inizializing the TCPIP protocol */ +#define ST_NET_NOVELL_INIT_ERROR -24 /* Error inizializing the Novell protocol */ +#define ST_NET_LOCAL_INIT_ERROR -25 /* Error inizializing the Local protocol */ +#define ST_NET_KEY_NOT_MAP -26 /* Not MAP programmed key found when MAP is requested */ + +/* + Code returned in data[0] after NET_OPEN +*/ +#define NET_TYPE_LOCAL 0 +#define NET_TYPE_IPX 1 +#define NET_TYPE_ANP 2 +#define NET_TYPE_TCPIP 3 + +/* + Structure definition +*/ +#pragma pack(push,1) + +typedef struct __KEY_NET { + short net_command; + unsigned long net_password; + short lpt; + short command; + unsigned char label[LABEL_LENGTH]; + unsigned char password[PASSWORD_LENGTH]; + unsigned char data[DATA_LENGTH]; + short fail_counter; + short status; + unsigned char ext_data[EXTENDED_DATA_LENGTH]; +} KEY_NET; + +#pragma pack(pop) + +/* + int smartlink_inizialize(void) + Inizialize the smartlink driver + Return 0 if successfull + + void smartlink_deinizialize(void) + Deinizialize the smartlink driver + Return 0 if successfull + + short smartlink(KEY_NET* key) + Call the driver. + Return key->k.status code +*/ +short __cdecl smartlink(KEY_NET*); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/server/soap.cpp b/server/xml.cpp similarity index 73% rename from server/soap.cpp rename to server/xml.cpp index f6bb97128..b08835cd0 100755 --- a/server/soap.cpp +++ b/server/xml.cpp @@ -1,10 +1,10 @@ -#include "wx/wx.h" -#include "wx/time.h" +#include +#include -#include "soap.h" +#include "xml.h" /////////////////////////////////////////////////////////// -// Utility +// Utilities /////////////////////////////////////////////////////////// wxOutputStream& operator<<(wxOutputStream& outf, const wxChar* str) @@ -14,13 +14,32 @@ wxOutputStream& operator<<(wxOutputStream& outf, const wxChar* str) return outf; } -wxOutputStream& operator<<(wxOutputStream& outf, const wxString str) +wxOutputStream& operator<<(wxOutputStream& outf, wxString str) { if (!str.IsEmpty()) outf.Write(str, str.Length()); return outf; } +wxInputStream& operator>>(wxInputStream& inf, wxString& str) +{ + const off_t nStart = inf.TellI(); + wxChar* buf = str.GetWriteBuf(256); + inf.Read(buf, 256); + str.UngetWriteBuf(); + const int nEol = str.Find('\n'); + if (nEol >= 0) + { + inf.SeekI(nStart+nEol+1); + str.Truncate(nEol); + str.Trim(); + } + else + inf.SeekI(nStart+str.Length()); + + return inf; +} + void Spaces(wxOutputStream& outf, int nSpaces) { outf << "\n"; @@ -32,6 +51,79 @@ void Spaces(wxOutputStream& outf, int nSpaces) } } +int hex2int(const wxChar* str) +{ + int n = 0; + for (int i = 0; str[i]; i++) + { + if (str[i] >= '0' && str[i] <= '9') + { + n *= 16; + n += str[i]-'0'; + } else + if (str[i] >= 'A' && str[i] <= 'F') + { + n *= 16; + n += str[i]-'A'+10; + } + else + break; + } + return n; +} + +wxString EscapeSequence(char cStart, wxInputStream& inf) +{ + wxString str; + + if (cStart == '&') + { + for (wxChar c = inf.GetC(); c != ';'; c = inf.GetC()) + str += c; + if (str == "lt") return str ="<"; + if (str == "gt") return str =">"; + if (str == "nbsp") return str =" "; + if (str == "Agrave") return str ="À"; + if (str == "Egrave") return str ="È"; + if (str == "Eacuto") return str ="É"; + if (str == "Igrave") return str ="Ì"; + if (str == "Ograve") return str ="Ò"; + if (str == "Ugrave") return str ="Ù"; + if (str == "agrave") return str ="à"; + if (str == "egrave") return str ="è"; + if (str == "eacuto") return str ="é"; + if (str == "igrave") return str ="ì"; + if (str == "ograve") return str ="ò"; + if (str == "ugrave") return str ="ù"; + str.Prepend(cStart); + } else + if (cStart == '%') + { + for (int i = 0; i < 2; i++) + str += inf.GetC(); + wxChar c = hex2int(str); + str = c; + } + + return str; +} + +void WriteXmlString(wxOutputStream& outf, const wxChar* str) +{ + for (int i = 0; str[i]; i++) + { + wxChar c = str[i]; + if (c < 0 || strchr("<>/&", c) != NULL) + { + unsigned int n = (unsigned char)c; + char str[8]; sprintf(str, "%%%02X", n); + outf << str; + } + else + outf << c; + } +} + /////////////////////////////////////////////////////////// // TXmlAttr /////////////////////////////////////////////////////////// @@ -49,16 +141,20 @@ public: void TXmlAttr::Write(wxOutputStream& outf) const { if (m_str.IsNumber()) + { outf << m_str; + } else + { outf << "\"" << m_str << "\""; + } } /////////////////////////////////////////////////////////// // TXmlItem /////////////////////////////////////////////////////////// -void TXmlItem::SetAttr(const wxChar* strAttr, const wxChar* strVal) +TXmlItem& TXmlItem::SetAttr(const wxChar* strAttr, const wxChar* strVal) { if (m_Attributes == NULL) { @@ -67,6 +163,7 @@ void TXmlItem::SetAttr(const wxChar* strAttr, const wxChar* strVal) } m_Attributes->Delete(strAttr); m_Attributes->Put(strAttr, new TXmlAttr(strVal)); + return *this; } wxString TXmlItem::GetAttr(const wxChar* strAttr) const @@ -135,7 +232,7 @@ wxString TXmlItem::GetWord(wxInputStream& inf) const break; if (c >= '\0' && c <= ' ') c = ' '; - str += char(c); + str += wxChar(c); } else { @@ -146,9 +243,8 @@ wxString TXmlItem::GetWord(wxInputStream& inf) const inf.Ungetch(char(c)); break; } - str += char(c); + str += wxChar(c); } - } return str; } @@ -164,7 +260,7 @@ int TXmlItem::ReadTag(wxInputStream& inf) bool bFirstChar = true; while (!inf.Eof()) { - const wxChar c = inf.GetC(); + wxChar c = inf.GetC(); if (c == '<') { inf.Ungetch(c); @@ -175,7 +271,10 @@ int TXmlItem::ReadTag(wxInputStream& inf) str << ' '; bFirstChar = false; } - str << c; + if (c == '&' || c == '#' || c == '%') + str += EscapeSequence(c, inf); + else + str << c; } SetTag(""); SetText(str); @@ -324,6 +423,21 @@ wxString TXmlItem::GetEnclosedText() const return text; } +TXmlItem& TXmlItem::AddEnclosedText(const wxChar* str) +{ + TXmlItem* item = FindFirst(""); + if (item == NULL) + item = &AddChild(""); + item->m_strText += str; + return *item; +} + +TXmlItem& operator<<(TXmlItem& item, const wxChar* str) +{ + item.AddEnclosedText(str); + return item; +} + void TXmlItem::Write(wxOutputStream& outf, int tab) const { if (!GetTag().IsEmpty()) @@ -369,7 +483,7 @@ wxString TXmlItem::AsString() const char* buf = str.GetWriteBuf(nSize); memset(buf, 0, nSize); wxMemoryOutputStream outf(buf, nSize); - Write(outf); + Write(outf, 0); str.UngetWriteBuf(); if (buf[nSize-1] == '\0') break; @@ -378,6 +492,12 @@ wxString TXmlItem::AsString() const return str; } +void TXmlItem::Save(const wxChar* strFilename) const +{ + wxFileOutputStream outf(strFilename); + Write(outf, 0); +} + static bool FindFirstCallback(TXmlItem& item, long jolly) { const wxChar* strTag = (const wxChar*)jolly; @@ -401,63 +521,3 @@ TXmlItem::~TXmlItem() delete m_Children; } -/////////////////////////////////////////////////////////// -// SoapProcess* -/////////////////////////////////////////////////////////// - -#include "Diction.h" - -bool SoapProcessMethod(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer) -{ - const wxString& strMethod = xmlMethod.GetTag(); - if (strMethod == "m:Translate") - return DoTranslate(xmlMethod, xmlAnswer); - - return false; -} - -wxString SoapProcessMessage(const char* buf, unsigned int len) -{ - TXmlItem xmlEnvelope; - xmlEnvelope.SetTag("SOAP-ENV:Envelope"); - TXmlItem& xmlBody = xmlEnvelope.AddChild("SOAP-ENV:Body"); - - const char* soapstart = strstr(buf, "GetChild(m); - if (pxmlMethod == NULL) - break; - if (pxmlMethod->GetTag().StartsWith("m:")) - { - wxString str = pxmlMethod->GetTag(); str += "Result"; - TXmlItem& xmlAnswer = xmlBody.AddChild(str); - SoapProcessMethod(*pxmlMethod, xmlAnswer); - } - } - } - } - const wxString strResult = xmlEnvelope.AsString(); - wxChar strLength[16]; sprintf(strLength, "%d", strResult.Length()); - - wxString strAnswer; - strAnswer += "HTTP/1.1 200 OK\n"; - strAnswer += "Connection: close\n"; - strAnswer += "Content-Length: "; strAnswer += strLength; - strAnswer += "\nContent-Type: text/xml; charset=utf-8\n"; - strAnswer += "Date: "; strAnswer += wxDateTime::Now().Format("%#c"); - strAnswer += "\nServer: "; strAnswer += wxGetHostName(); - strAnswer += "\r\n\r\n"; - strAnswer += strResult; - - return strAnswer; -} - diff --git a/server/soap.h b/server/xml.h similarity index 68% rename from server/soap.h rename to server/xml.h index caf03fa2f..cc198a625 100755 --- a/server/soap.h +++ b/server/xml.h @@ -1,5 +1,5 @@ -#ifndef __SOAP_H -#define __SOAP_H +#ifndef __XML_H +#define __XML_H #ifndef _WX_WXMMSTREAM_H__ #include "wx/mstream.h" @@ -28,9 +28,11 @@ public: const wxString& GetText() const { return m_strText; } void SetText(const wxChar* str) { m_strText = str; } + + TXmlItem& AddEnclosedText(const wxChar* str); wxString GetEnclosedText() const; - void SetAttr(const wxChar* strAttr, const wxChar* strVal); + TXmlItem& SetAttr(const wxChar* strAttr, const wxChar* strVal); wxString GetAttr(const wxChar* strAttr) const; TXmlItem& AddChild(const wxChar* strTag); @@ -41,9 +43,11 @@ public: TXmlItem* GetChild(size_t n) const; bool Read(wxInputStream& input); - void Write(wxOutputStream& output, int nTab = 0) const; + void Write(wxOutputStream& output, int nTab) const; wxString AsString() const; + void Save(const wxChar* strFilename) const; + TXmlItem* ForEach(XmlItemCallback cb, long jolly = 0); TXmlItem* FindFirst(const wxChar* strTag) const; @@ -51,9 +55,16 @@ public: ~TXmlItem(); }; -wxOutputStream& operator<<(wxOutputStream& outf, const wxChar* str); -wxOutputStream& operator<<(wxOutputStream& outf, const wxString str); +TXmlItem& operator<<(TXmlItem& item, const wxChar* str); -wxString SoapProcessMessage(const char* buf, const unsigned int len); +wxOutputStream& operator<<(wxOutputStream& outf, const wxChar* str); +wxOutputStream& operator<<(wxOutputStream& outf, wxString str); +wxInputStream& operator>>(wxInputStream& inf, wxString& str); +void Spaces(wxOutputStream& outf, int nSpaces); +void WriteXmlString(wxOutputStream& outf, const wxChar* str); +int hex2int(const wxChar* str); + +#define endl "\r\n"; #endif + diff --git a/ve/ve0100.cpp b/ve/ve0100.cpp index 6f1c5f507..d9097637c 100755 --- a/ve/ve0100.cpp +++ b/ve/ve0100.cpp @@ -284,9 +284,9 @@ void TMotore_application::on_firm_change() bool TMotore_application::user_create( ) { open_files(LF_DOC, LF_RIGHEDOC, LF_CONDV, LF_RCONDV, LF_ANAMAG, LF_SCONTI, LF_UMART, LF_DESLIN, LF_CODCORR, - LF_TAB, LF_TABCOM, LF_CLIFO, LF_CFVEN, LF_INDSP, LF_OCCAS, LF_PCON, - LF_MOVMAG, LF_RMOVMAG, LF_MAG, LF_SVRIEP, LF_AGENTI, LF_PERCPROV, LF_ATTIV, LF_CAUSALI, 0); - + LF_TAB, LF_TABCOM, LF_CLIFO, LF_CFVEN, LF_INDSP, LF_OCCAS, LF_PCON, + LF_MOVMAG, LF_RMOVMAG, LF_MAG, LF_SVRIEP, LF_AGENTI, LF_PERCPROV, LF_ATTIV, LF_CAUSALI, 0); + _config_ditta = new TConfig(CONFIG_DITTA); // Metto in relazione testata e righe diff --git a/ve/ve0200g.uml b/ve/ve0200g.uml index 22b4133c7..ba4c0e569 100755 --- a/ve/ve0200g.uml +++ b/ve/ve0200g.uml @@ -507,7 +507,6 @@ BEGIN FIELD CHK_USER[9] END - STRING F_PROMPT_USER9 20 BEGIN PROMPT 2 12 "Prompt " diff --git a/xi/xi.c b/xi/xi.c index a1b4c29fa..2957ba7c1 100755 --- a/xi/xi.c +++ b/xi/xi.c @@ -122,6 +122,7 @@ call_cb( XI_OBJ * itf, XI_EVENT * xiev ) itf_data = itf->v.itf; itf_data->in_callback++; XinCoalesceInvalidates( itf_data->xin_win, TRUE ); + ( *itf_data->xi_eh ) ( ( struct _xi_obj * ) itf, xiev ); #ifdef WINRUNNER xir_record( itf, xiev ); @@ -639,8 +640,7 @@ do_edit_menu( XI_OBJ * itf, XinEvent * ep ) } if ( attrib & XI_ATR_EDITMENU ) { - int b, - e; + int b, e; switch ( ep->v.menu_command.tag ) { @@ -648,7 +648,14 @@ do_edit_menu( XI_OBJ * itf, XinEvent * ep ) copy_to_clip( focus_obj ); /* fall through */ case XI_MENU_EDIT_CLEAR: - xi_get_sel( focus_obj, &b, &e ); + xi_get_sel( focus_obj, &b, &e ); +#if 1 // #ifdef XVAGA + if ( b == e ) + { + e++; + xi_set_sel( focus_obj, b, e ); + } +#endif if ( b != e ) { XinEvent ev; @@ -2213,15 +2220,13 @@ xi_event( XinWindow win, XinEvent * ep ) new_cursor = XI_CURSOR_IBEAM; break; case 2: - new_cursor = - ( XinCursor ) xi_get_pref( XI_PREF_SIZE_CURSOR_RID ); + new_cursor = ( XinCursor) xi_get_pref( XI_PREF_SIZE_CURSOR_RID ); break; case 3: - new_cursor = - ( XinCursor ) xi_get_pref( XI_PREF_HAND_CURSOR_RID ); + new_cursor = ( XinCursor ) xi_get_pref( XI_PREF_HAND_CURSOR_RID ); break; case 4: - new_cursor = XI_CURSOR_CROSS; + new_cursor = XI_CURSOR_CROSS; break; case 5: new_cursor = XI_CURSOR_ARROW; diff --git a/xi/xi2.c b/xi/xi2.c index 8e1bd4ded..79afdd28d 100755 --- a/xi/xi2.c +++ b/xi/xi2.c @@ -1393,6 +1393,8 @@ xi_lm_cb( LM_CB_DATA * lm_cb_data ) XI_LIST_DATA *ldata; LM_DATA *lmp; + XI_OBJ row_obj; // AGA: dichiarato oggetto locale di cui altrimenti si perde traccia nell'evento! + MEMCLEAR( xiev ); lm_obj = ( XI_OBJ * ) lm_get_list_obj( lm_cb_data->lm ); lmp = ( LM_DATA * ) lm_obj->v.list->lm; @@ -1550,12 +1552,9 @@ xi_lm_cb( LM_CB_DATA * lm_cb_data ) } else { - XI_OBJ row_obj; +// XI_OBJ row_obj; AGA was here XI_MAKE_ROW( &row_obj, lm_obj, lm_cb_data->row ); - if (row_obj.parent == NULL) - xvt_debug_printf("AGA: lost parent"); - xiev.type = XIE_SELECT; xiev.v.select.xi_obj = &row_obj; xiev.v.select.selected = lm_cb_data->v.select.selected; @@ -1570,7 +1569,7 @@ xi_lm_cb( LM_CB_DATA * lm_cb_data ) } case LM_CB_ROW_SIZE: { - XI_OBJ row_obj; + // XI_OBJ row_obj; AGA was here XI_MAKE_ROW( &row_obj, lm_obj, lm_cb_data->row ); xiev.type = XIE_ROW_SIZE; diff --git a/xi/xilm3.c b/xi/xilm3.c index fdc8664fb..8665eb4e9 100755 --- a/xi/xilm3.c +++ b/xi/xilm3.c @@ -4070,7 +4070,6 @@ lm_event( XI_OBJ * itf, LM lm, XinEvent * ep ) else { unsigned long attrib; - attrib = lm_get_attrib( lm, LM_ROW, row, 0, FALSE ); if ( lmp->drag_and_drop_rows && ( attrib & LM_ROW_ATR_SELECTED ) != 0 && !ep->v.mouse.shift ) diff --git a/xi/xiport.c b/xi/xiport.c index d4d17d7c8..1df3dbbf5 100755 --- a/xi/xiport.c +++ b/xi/xiport.c @@ -1413,10 +1413,12 @@ BrushPatternToPAT( XinBrushPattern Pattern ) { switch ( Pattern ) { -case XinBrushSolid: + case XinBrushSolid: return PAT_SOLID; case XinBrushHollow: return PAT_HOLLOW; + default: + break; } return PAT_SOLID; } @@ -1426,12 +1428,14 @@ PenPatternToPAT( XinPenPattern Pattern ) { switch ( Pattern ) { -case XinPenSolid: + case XinPenSolid: return PAT_SOLID; case XinPenHollow: return PAT_HOLLOW; case XinPenDashed: return PAT_RUBBER; + default: + break; } return PAT_SOLID; } @@ -3469,13 +3473,15 @@ XinWindowPenSet( XinWindow win, XinPen * Pen ) cpen.width = Pen->width; switch ( Pen->pattern ) { - case XinPenSolid: - case XinPenHollow: - cpen.style = P_SOLID; - break; case XinPenDashed: cpen.style = P_DASH; break; + case XinPenDotted: + cpen.style = P_DOT; + break; + default: + cpen.style = P_SOLID; + break; } #if XIWS == XIWS_WM xi_fix_color( &cpen.color ); diff --git a/xi/xiport.h b/xi/xiport.h index 1b927b8e8..efd672e3c 100755 --- a/xi/xiport.h +++ b/xi/xiport.h @@ -414,7 +414,8 @@ typedef enum { XinPenHollow, XinPenSolid, - XinPenDashed + XinPenDashed, + XinPenDotted, // Added by Guy } XinPenPattern; /* NEW */ diff --git a/xi/xiutils.c b/xi/xiutils.c index 0492f0ee8..96d0897aa 100755 --- a/xi/xiutils.c +++ b/xi/xiutils.c @@ -16,6 +16,8 @@ #include "xistx.h" #include "xilm.h" #include "xilmst.h" +#include "xiport.h" + #if XIWS == XIWS_WM #define STX_VERT_FUDGE 0 @@ -3829,6 +3831,20 @@ xi_cr_is_ok( XI_OBJ * xi_obj ) void xi_draw_dotted_rect( XinWindow win, XinRect * rctp ) { +#ifdef TRUE + XinDrawTools dt; + XinPen pen; + + XinWindowDrawToolsGet(win, &dt); + pen.width = 0; + pen.pattern = XinPenDotted; + pen.fore_color = dt.pen.fore_color; + XinWindowPenSet(win, &pen); + XinWindowBrushSet(win, &hollow_cbrush); + xi_draw_rect(win, rctp); + + XinWindowDrawToolsSet(win, &dt); +#else XinPoint p1, p2, p3, @@ -3862,6 +3878,7 @@ xi_draw_dotted_rect( XinWindow win, XinRect * rctp ) xi_move_to( win, p3 ); xi_draw_line( win, p4 ); } +#endif } BOOLEAN diff --git a/xvaga/oswin32.cpp b/xvaga/oswin32.cpp index 774dd40d5..ee2a0ef0e 100755 --- a/xvaga/oswin32.cpp +++ b/xvaga/oswin32.cpp @@ -2,11 +2,15 @@ #include "oswin32.h" +#include "xvt_menu.h" +#include "xvt_help.h" + #define WIN32_LEAN_AND_MEAN #define WIN32_EXTRA_LEAN #define STRICT #include #include +#include bool OsWin32_CheckPrinterInfo(const void* data, unsigned int size) { @@ -229,3 +233,41 @@ void OsWin32_Beep(int severity) default: MessageBeep(MB_ICONSTOP); break; } } + +int OsWin32_Help(unsigned int handle, const char* hlp, unsigned int cmd, const char* topic) +{ + HWND hwnd = (HWND)handle; + + switch(cmd) + { + case M_HELP_CONTENTS: + ::WinHelp(hwnd, hlp, HELP_CONTENTS, 0); + break; + case M_HELP_SEARCH: + ::WinHelp(hwnd, hlp, HELP_PARTIALKEY, (DWORD)""); + break; + case M_HELP_HELPONHELP: + ::WinHelp(hwnd, hlp, HELP_HELPONHELP, 0); + break; + case M_HELP_ONCONTEXT: + if (topic != NULL) + { + struct MULTIGUY + { + DWORD mkSize; + TCHAR mkKeylist; + TCHAR mkKeyphrase[16]; + } mk; + + mk.mkSize = sizeof(MULTIGUY); + mk.mkKeylist = 'M'; + strncpy(mk.mkKeyphrase, topic, sizeof(mk.mkKeyphrase)); + ::WinHelp(hwnd, hlp, HELP_MULTIKEY, (DWORD)&mk); + } + break; + default: + ::WinHelp(hwnd, hlp, HELP_QUIT, 0); + break; + } + return TRUE; +} diff --git a/xvaga/oswin32.h b/xvaga/oswin32.h index 5930eb43b..63c08369d 100755 --- a/xvaga/oswin32.h +++ b/xvaga/oswin32.h @@ -13,3 +13,4 @@ void OsWin32_StretchBlt(unsigned int hDst, int xd, int yd, int wd, int hd, unsigned int hSrc, int xs, int ys, int ws, int hs); void OsWin32_UpdateWindow(unsigned int handle); +int OsWin32_Help(unsigned int handle, const char* hlp, unsigned int cmd, const char* topic); diff --git a/xvaga/xvaga.cpp b/xvaga/xvaga.cpp index ea0d48554..0d4df5682 100755 --- a/xvaga/xvaga.cpp +++ b/xvaga/xvaga.cpp @@ -8,6 +8,9 @@ #include "wx/print.h" #include "wx/printdlg.h" +#include "wx/fs_zip.h" +#include "wx/html/helpctrl.h" + #include "xvt.h" #include "statbar.h" @@ -276,6 +279,7 @@ int TMainApp::OnExit() /////////////////////////////////////////////////////////// #define CAST_COLOR(xc, wc) wxColour wc((xc>>16)&0xFF, (xc>>8)&0xFF, xc&0xFF) +#define MAKE_XVT_COLOR(wc) MAKE_COLOR(wc.Red(), wc.Green(), wc.Blue()) TDC::TDC(wxWindow* owner) : _dc(NULL) { @@ -1395,6 +1399,130 @@ char* xvt_dm_post_string_prompt(const char* message, char* response, int respons return NULL; } +/////////////////////////////////////////////////////////// +// Help system +/////////////////////////////////////////////////////////// + +struct XVAGA_HELP_INFO +{ + wxString m_strFilename; + bool m_hlp; + wxHtmlHelpController m_hc; +} help_info; + +XVT_HELP_INFO xvt_help_open_helpfile(FILE_SPEC *fs, unsigned long flags) +{ + if (!help_info.m_strFilename.IsEmpty()) + xvt_help_close_helpfile((XVT_HELP_INFO)&help_info); + + const char* ext[] = { ".zip", ".htb", ".hlp", NULL }; + for (int j = 0; j < 2; j++) + { + wxString base = fs->name; + if (j == 1) + base.Replace("campo", "prassi", true); + for (int i = 0; ext[i]; i++) + { + wxString strName; + if (i < 2) + strName = "help/"; + strName << base; + strName << ext[i]; + if (::wxFileExists(strName)) + { + help_info.m_strFilename = strName; + help_info.m_hlp = i == 2; + if (!help_info.m_hlp) + { + wxFileSystem::AddHandler(new wxZipFSHandler); + help_info.m_hc.AddBook(strName, true); + } + return (XVT_HELP_INFO)&help_info; + } + } + } + return NULL_HELP_INFO; +} + +void xvt_help_close_helpfile(XVT_HELP_INFO hi) +{ + if (hi == NULL_HELP_INFO) + hi = (XVT_HELP_INFO)&help_info; + + XVAGA_HELP_INFO* ahi = (XVAGA_HELP_INFO*)hi; + if (!ahi->m_strFilename.IsEmpty()) + { +#ifdef WIN32 + if (ahi->m_hlp) + { + unsigned int hwnd = (unsigned int)xvt_vobj_get_attr(TASK_WIN, ATTR_NATIVE_WINDOW); + OsWin32_Help(hwnd, ahi->m_strFilename, 0, NULL); // HELP_QUIT + } +#endif + if (!ahi->m_hlp) + ahi->m_hc.Quit(); + ahi->m_strFilename.Empty(); + } +} + +BOOLEAN xvt_help_process_event(XVT_HELP_INFO hi, WINDOW win, EVENT *ev) +{ + BOOLEAN bProcessed = FALSE; + + if (hi == NULL_HELP_INFO) + return bProcessed; + + XVAGA_HELP_INFO* ahi = (XVAGA_HELP_INFO*)hi; + if (ahi->m_strFilename.IsEmpty()) + return bProcessed; + +#ifdef WIN32 + if (ahi->m_hlp) + { + unsigned int hwnd = (unsigned int)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW); + switch (ev->type) + { + case E_COMMAND: + bProcessed = OsWin32_Help(hwnd, ahi->m_strFilename, ev->v.cmd.tag, NULL); + break; + case E_HELP: + bProcessed = OsWin32_Help(hwnd, ahi->m_strFilename, M_HELP_ONCONTEXT, (const char*)ev->v.help.tid); + break; + default: + break; + } + return bProcessed; + } +#endif + + switch (ev->type) + { + case E_COMMAND: + switch (ev->v.cmd.tag) + { + case M_HELP_CONTENTS: + ahi->m_hc.DisplayContents(); + bProcessed = TRUE; + break; + case M_HELP_SEARCH: + ahi->m_hc.DisplayIndex(); + bProcessed = TRUE; + break; + default: + break; + } + break; + case E_HELP: + ahi->m_hc.Display((const char*)ev->v.help.tid); + bProcessed = TRUE; + break; + default: + break; + } + + return bProcessed; +} + /////////////////////////////////////////////////////////// // Image handling /////////////////////////////////////////////////////////// @@ -2361,7 +2489,6 @@ void xvt_menu_translate_tree(WINDOW win, TRANSLATE_CALLBACK tc) wxMenu* pMenu = pMenuBar->GetMenu(m); TranslateMenu(pMenu, tc); } -// w.SetMenuBar(pMenuBar); } } } @@ -2967,8 +3094,30 @@ long xvt_vobj_get_attr(WINDOW win, long data) long ret = 0L; switch(data) { - case ATTR_CTL_VERT_SBAR_WIDTH: ret = wxSystemSettings::GetSystemMetric(wxSYS_VSCROLL_X); break; - case ATTR_CTL_HORZ_SBAR_HEIGHT: ret = wxSystemSettings::GetSystemMetric(wxSYS_HSCROLL_Y); break; + case ATTR_APP_CTL_COLORS: + { + XVT_COLOR_COMPONENT* xcc = (XVT_COLOR_COMPONENT*)xvt_mem_zalloc(sizeof(XVT_COLOR_COMPONENT)*6); + xcc[0].type = XVT_COLOR_FOREGROUND; + xcc[0].color = MAKE_XVT_COLOR(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_BTNTEXT)); + xcc[1].type = XVT_COLOR_BACKGROUND; + xcc[1].color = MAKE_XVT_COLOR(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_BTNFACE)); + xcc[2].type = XVT_COLOR_CAPTIONLT; + xcc[2].color = MAKE_XVT_COLOR(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_ACTIVECAPTION)); + xcc[3].type = XVT_COLOR_CAPTIONDK; + xcc[3].color = MAKE_XVT_COLOR(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_INACTIVECAPTION)); + xcc[4].type = XVT_COLOR_CAPTIONTEXT; + xcc[4].color = MAKE_XVT_COLOR(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_CAPTIONTEXT)); + xcc[5].type = XVT_COLOR_NULL; + xcc[5].color = 0; + ret = (long)xcc; + } + break; + case ATTR_CTL_VERT_SBAR_WIDTH: + ret = wxSystemSettings::GetSystemMetric(wxSYS_VSCROLL_X); + break; + case ATTR_CTL_HORZ_SBAR_HEIGHT: + ret = wxSystemSettings::GetSystemMetric(wxSYS_HSCROLL_Y); + break; case ATTR_DISPLAY_TYPE: switch (::wxDisplayDepth()) { @@ -2978,7 +3127,9 @@ long xvt_vobj_get_attr(WINDOW win, long data) default: ret = XVT_DISPLAY_DIRECT_COLOR; break; } break; - case ATTR_ERRMSG_HANDLER: ret = (long)_error_handler; break; + case ATTR_ERRMSG_HANDLER: + ret = (long)_error_handler; + break; case ATTR_NATIVE_GRAPHIC_CONTEXT: { CAST_DC(win, dc); @@ -2992,9 +3143,14 @@ long xvt_vobj_get_attr(WINDOW win, long data) } break; case ATTR_SCREEN_WINDOW: - ret = NULL_WIN; break; // Non bellissimo ma per ora... - case ATTR_TASK_WINDOW: ret = long(_task_win); break; - case ATTR_WIN_PM_DRAWABLE_TWIN: ret = TRUE; break; + ret = NULL_WIN; // Non bellissimo ma per ora... + break; + case ATTR_TASK_WINDOW: + ret = long(_task_win); + break; + case ATTR_WIN_PM_DRAWABLE_TWIN: + ret = TRUE; + break; default: SORRY_BOX(); break; } return ret; @@ -3170,7 +3326,8 @@ WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WIN w = new TwxWindow((wxWindow*)parent, -1, caption, pos, size, style); w->_type = wtype; w->_app_data = app_data; - if (win_flags & WSF_INVISIBLE) + + if (win_flags & WSF_INVISIBLE) w->Hide(); else w->Show(); @@ -3179,7 +3336,7 @@ WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WIN OsWin32_SetCaptionStyle(w->GetHWND(), wtype == W_DOC); #endif - if (menu_rid > 0 && menu_rid != 8000) // 8000 = NULL_MENU_RID + if (menu_rid > 0 && menu_rid != 8000) // 8000 = NULL_MENU_RID { MENU_ITEM* mi = xvt_res_get_menu(menu_rid); if (mi) @@ -3199,6 +3356,8 @@ WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WIN else w->Enable(); + xvt_vobj_move((WINDOW)w, rct_p); + // Accetta messaggi solo da ora! w->_eh = eh; diff --git a/xvaga/xvt.h b/xvaga/xvt.h index 0690df1ed..2159bed2c 100755 --- a/xvaga/xvt.h +++ b/xvaga/xvt.h @@ -129,6 +129,10 @@ void xvt_fsys_restore_dir(); void xvt_fsys_save_dir(); BOOLEAN xvt_fsys_set_dir(DIRECTORY *dirp); +void xvt_help_close_helpfile(XVT_HELP_INFO hi); +XVT_HELP_INFO xvt_help_open_helpfile(FILE_SPEC *fs, unsigned long flags); +BOOLEAN xvt_help_process_event(XVT_HELP_INFO hi, WINDOW win, EVENT *ev); + XVT_IMAGE xvt_image_create(XVT_IMAGE_FORMAT format, short width, short height, long reserved); void xvt_image_destroy(XVT_IMAGE image); COLOR xvt_image_get_clut(XVT_IMAGE image, short index); diff --git a/xvaga/xvt_defs.h b/xvaga/xvt_defs.h index 70deed00f..366939e2f 100755 --- a/xvaga/xvt_defs.h +++ b/xvaga/xvt_defs.h @@ -5,7 +5,7 @@ * Agreement with XVT Software. * * $RCSfile: xvt_defs.h,v $ - * $Revision: 1.1 $ + * $Revision: 1.2 $ * * Purpose: Global XVT macro definitions. * @@ -537,6 +537,9 @@ #define XVT_COLOR_BORDER (XVT_COLOR_TYPE)(1L<<5) #define XVT_COLOR_TROUGH (XVT_COLOR_TYPE)(1L<<6) #define XVT_COLOR_SELECT (XVT_COLOR_TYPE)(1L<<7) - +// Added by XVAGA +#define XVT_COLOR_CAPTIONLT (XVT_COLOR_TYPE)(1L<<8) +#define XVT_COLOR_CAPTIONDK (XVT_COLOR_TYPE)(1L<<9) +#define XVT_COLOR_CAPTIONTEXT (XVT_COLOR_TYPE)(1L<<10) #endif /* XVT_INCL_DEFS */