From 10b448f7fc49ac77e0f28ae300c6e0922f25dab3 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 24 Feb 1998 10:31:42 +0000 Subject: [PATCH] Eliminate le dipendenze dal sistema operativo usando os_dep.h git-svn-id: svn://10.65.10.50/trunk@6250 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg4100.cpp | 66 ++++++++++++++--------------------------------- cg/cg4301.cpp | 26 ++++++++----------- cg/cg4400.cpp | 69 +++++++++++++++++++++++++++++++++----------------- cg/cg4400.h | 21 +-------------- cg/cglib04.cpp | 20 ++------------- 5 files changed, 78 insertions(+), 124 deletions(-) diff --git a/cg/cg4100.cpp b/cg/cg4100.cpp index f89a26878..550b26ebd 100755 --- a/cg/cg4100.cpp +++ b/cg/cg4100.cpp @@ -6,14 +6,11 @@ // *TBI* Aggiornamento cespiti // ------------------------------------------------------------------------- -#include - #include #include #include #include #include -#include #include #define FLD_CG41_YEAR 100 @@ -36,7 +33,7 @@ struct therec { char NUMREG[8]; }; -class CG4100_App : public TApplication +class CG4100_App : public TSkeleton_application { int _year; char _optype; @@ -44,58 +41,20 @@ class CG4100_App : public TApplication public: - virtual bool create(); - virtual bool destroy(); bool set_parms(); - virtual bool menu(MENU_TAG m); + virtual void main_loop(); void restore_mov(TSystemisamfile& a, TSystemisamfile& b, TSystemisamfile& c); void sort_all(); bool sort_mov(); bool sort_sal(); - CG4100_App() : TApplication(), _optype('S') {} + CG4100_App() : _optype('S') {} virtual ~CG4100_App() {} }; -bool CG4100_App::create() -{ - TApplication::create(); - - // UNIX: signal() per intercettare errori -#if XVT_OS == XVT_OS_SCOUNIX - signal(SIGINT,SIG_IGN); -#endif - - if (fexist("__sal__.sav")) - warning_box("Un'operazione di riordino saldi si e' conclusa" - " impropriamente. Si raccomanda di rieseguirla"); - - if (fexist("__mov__.sav")) - warning_box("Un'operazione di riordino movimenti si e' conclusa" - " impropriamente. Si raccomanda di rieseguirla"); - - if (argc() > 2) - _optype = toupper(argv(2)[0]); - - _msk = new TMask(_optype == 'S' ? "cg4100b" : "cg4100a"); - - dispatch_e_menu(MENU_ITEM(1)); - return TRUE; -} - -bool CG4100_App::destroy() -{ - // UNIX: resettare i segnali -#if XVT_OS == XVT_OS_SCOUNIX - signal(SIGINT,SIG_DFL); -#endif - delete _msk; - return TApplication::destroy(); -} - bool CG4100_App::set_parms() { _msk->run(); @@ -109,14 +68,27 @@ bool CG4100_App::set_parms() } -bool CG4100_App::menu(MENU_TAG) -{ +void CG4100_App::main_loop() +{ + if (fexist("__sal__.sav")) + warning_box("Un'operazione di riordino saldi si e' conclusa" + " impropriamente. Si raccomanda di rieseguirla"); + + if (fexist("__mov__.sav")) + warning_box("Un'operazione di riordino movimenti si e' conclusa" + " impropriamente. Si raccomanda di rieseguirla"); + + if (argc() > 2) + _optype = toupper(argv(2)[0]); + + _msk = new TMask(_optype == 'S' ? "cg4100b" : "cg4100a"); + if (_optype == 'S') sort_sal(); else sort_mov(); - return FALSE; + delete _msk; } diff --git a/cg/cg4301.cpp b/cg/cg4301.cpp index e35031d39..26410ddb0 100755 --- a/cg/cg4301.cpp +++ b/cg/cg4301.cpp @@ -4,24 +4,18 @@ // fv 21-1-94 // ------------------------------------------------------------ +#include +#include #include #include -#include -#include + +#include "cg4300.h" + #include #include #include #include #include -#include "cg4300.h" - -#ifdef DBG -#if XVT_OS == XVT_OS_WIN -#define STRICT -#include -#endif -#endif - // -------------------- QUI comincia l'avventura -------------------------- // Datemi un punto di appoggio ****************** @@ -243,7 +237,7 @@ bool TLiquidazione_app::update_firm(int month, bool recalc) TString yr(_year); real pr1 = _pla->get_real("R8"); // Percentuale prorata anno attuale const int anno = atoi(_year); - _year = format("%d", anno - 1); + _year.format("%d", anno - 1); const bool flag = look_pla(cattiv, FALSE); // Reperisce percentuale prorata anno precedente real pr2 = _pla->get_real("R8"); _year = yr; // Risetta l'anno corretto e riposiziona la tabella... @@ -589,7 +583,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) { #ifdef DBG msgdbg.format("Ricalcolo attivita': %ld/%ld",_cur->pos(),items); - freespace = GetFreeSpace(0); + freespace = os_get_free_memory(); msgdbg << " Memoria libera: " << freespace/1024 << " Kbytes."; xvt_statbar_set(msgdbg); #endif @@ -2231,7 +2225,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts) // precedente differita = TRUE; TString yr(_year); - _year = format("%d", year_int-1); + _year.format("%d", year_int-1); if (!look_lim(12)) //controlla solamente, il vero posizionamento lo fa dopo { _year = yr; @@ -2368,7 +2362,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts) // counter attivita' per evitare troppi versamenti attc++; if (differita) - _year = format("%d", atoi(_year)+1); + _year.format("%d", atoi(_year)+1); if (!(_isdifferita && is_first_month(month+deltam))) { @@ -2497,7 +2491,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts) // scrivi nuovo prorata in tabella anno successivo TString yr = _year; - _year = format("%d", atoi(_year) + 1); + _year.format("%d", atoi(_year) + 1); look_pla(att, TRUE); _pla->put("R8", prorata); _pla->rewrite(); diff --git a/cg/cg4400.cpp b/cg/cg4400.cpp index aab5ce91c..44519b490 100755 --- a/cg/cg4400.cpp +++ b/cg/cg4400.cpp @@ -1,12 +1,33 @@ // ******************* // Stampa registri IVA // ******************* + +#include +#include +#include +#include +#include +#include +#include +#include + #include "cg4.h" #include "cg4400.h" #include "cg4400a.h" #include "cg4400b.h" #include "cglib01.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + + inline CG4400_application& app() { return (CG4400_application&)main_app(); } #define RIGHE_FOOTER 1 // Righe da saltare nel footer per evitare di scrivere sulla perforazione @@ -72,7 +93,8 @@ bool CG4400_application::stampa_datareg() const char* CG4400_application::descr_doc() { TTable tab_tpd("%TPD"); - TString codtab(format("%-2s",(const char*) _tipodoc)); + TString16 codtab; + codtab.format("%-2s",(const char*)_tipodoc); tab_tpd.zero(); tab_tpd.put("CODTAB", codtab); @@ -87,7 +109,8 @@ const char* CG4400_application::descr_doc() const char* CG4400_application::descr_iva(const char* cod) { TTable tab_iva("%IVA"); - TString codtab(format ("%-4s", cod)); + TString16 codtab; + codtab.format ("%-4s", cod); tab_iva.zero(); tab_iva.put("CODTAB", codtab); @@ -467,7 +490,7 @@ bool CG4400_application::compila_lib() bool CG4400_application::cerca_libro_gio(TString& datas, bool* good) { TString app(4); - app = format("%04d", _annoes); + app.format("%04d", _annoes); *good = TRUE; TRecnotype rec = _tabreg->recno(); @@ -766,8 +789,8 @@ bool CG4400_application::mask_libun (TMask_field& f, KEY k) if (last_mese == 13) last_mese = 0; //l'ultima data di stampa sul/sui registri specificati e' vuota //(cioe' non sono ancora stati stampati sul libro unico specificato) - const char* me = ""; - me = format("%02d", last_mese); + TString16 me; + me.format("%02d", last_mese); f.mask().set(ULTIMO_MESE, me); delete p; } @@ -884,7 +907,7 @@ bool CG4400_application::to_ditt_handler(TMask_field& f, KEY key) { const long l = app().select_firm_range(m.get_long(DA_CODICE), m.get_long(A_CODICE)); app().set_choice_limits(m); - m.field(F_SELECT).set(format("%ld", l)); + m.set(F_SELECT, l); } return TRUE; } @@ -910,7 +933,7 @@ bool CG4400_application::fr_ditt_handler(TMask_field& f, KEY key) { const long l = app().select_firm_range(m.get_long(DA_CODICE), m.get_long(A_CODICE)); app().set_choice_limits(m); - m.field(F_SELECT).set(format("%ld", l)); + m.set(F_SELECT, l); } return TRUE; } @@ -927,8 +950,8 @@ void CG4400_application::set_choice_limits(TMask& m) if (last < dit) last = dit; } } - if (first != -1) m.field(DA_CODICE).set(format("%ld",first)); - if (last != -1) m.field(A_CODICE).set(format("%ld",last)); + if (first != -1) m.set(DA_CODICE, first); + if (last != -1) m.set(A_CODICE, last); m.set(F_SELECT, _selected.ones()); //modifica del 02/06/1995 if (m.is_running()) @@ -1401,7 +1424,7 @@ messaggio CG4400_application::controlla_liquidazione() for (i=3; i<=mese; i+=3) { chiave = ""; - TString16 m (format("%02d", i)); + TString16 m; m.format("%02d", i); chiave << _annoes << m; lim.put("CODTAB", chiave); if (lim.read() != NOERR || !lim.get_bool("B0")) @@ -1413,7 +1436,7 @@ messaggio CG4400_application::controlla_liquidazione() for (i=1 ; i<=mese; i++) { chiave = ""; - TString16 m (format("%02d", i)); + TString16 m; m.format("%02d", i); chiave << _annoes << m; lim.put("CODTAB", chiave); if (lim.read() != NOERR || !lim.get_bool("B0")) @@ -1451,7 +1474,7 @@ messaggio CG4400_application::controlla_liquidazione() (m==3 || m==6 || m==9 || m==12)) { chiave = ""; - TString16 m (format("%02d", m)); + TString16 m; m.format("%02d", m); chiave << _annoes << m; lim.put("CODTAB", chiave); if (lim.read() != NOERR || !lim.get_bool("B0")) @@ -1851,15 +1874,12 @@ void CG4400_application::stampa_plafonds(int r) if ( _tipo_stampa == 2 || _tipo_stampa == 4 ) num = _datareg.month(); - TString16 nm (format("%02d", num)); + TString16 nm; nm.format("%02d", num); // forza il tipoatt a 1 //char buf[10]; strcpy(buf,_codatt); //buf[strlen(buf) - 1] = '1'; - chiave = ""; - //chiave << _annoes << buf; - chiave.format("%05ld", get_firm()); chiave << _annoes; chiave << _codatt << "1"; @@ -1997,7 +2017,7 @@ real CG4400_application::stampa_valori_plafonds(const real& r1, const int mese, for (i=1; i #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include + #include "cglib03.h" -#include "cglib04.h" enum messaggio { no_liquidazione, diff --git a/cg/cglib04.cpp b/cg/cglib04.cpp index 111fc49ea..cd632deaf 100755 --- a/cg/cglib04.cpp +++ b/cg/cglib04.cpp @@ -3024,11 +3024,7 @@ void TTransfer_file::new_key(TString& key, int tipo, TString& buffer) //in un file con record odinati in modo sequenziale bool TTransfer_file::ordina_trasfer(const char* orig) { -#if XVT_OS == XVT_OS_SCOUNIX - const char* const rflag = "r"; -#else const char* const rflag = "rb"; -#endif open(orig); @@ -3104,14 +3100,8 @@ bool TTransfer_file::fcopytemp(const char* orig, const char* dest) long nrec_cau,nrec_clifo,nrec_pcon,nrec_mov,nrec_moviva,nrec_salda; bool is_delete = FALSE; - const char* wflag; -#if XVT_OS == XVT_OS_SCOUNIX - const char* const rflag = "r"; - wflag = "a"; -#else const char* const rflag = "rb"; - wflag = "ab"; -#endif + const char* const wflag = "ab"; ordina_trasfer(orig); @@ -3503,14 +3493,8 @@ bool TTransfer_file::fcopytemp_PC(const char* orig, const char* dest) TString sigle; bool is_delete = FALSE; - const char* wflag; -#if XVT_OS == XVT_OS_SCOUNIX - const char* const rflag = "r"; - wflag = "a"; -#else const char* const rflag = "rb"; - wflag = "ab"; -#endif + const char* const wflag = "ab"; // Legge numero di rec. del trasfer (per la progind) open(orig);