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
This commit is contained in:
guy 1998-02-24 10:31:42 +00:00
parent d70d456f1e
commit 10b448f7fc
5 changed files with 78 additions and 124 deletions

View File

@ -6,14 +6,11 @@
// *TBI* Aggiornamento cespiti
// -------------------------------------------------------------------------
#include <signal.h>
#include <applicat.h>
#include <isam.h>
#include <mask.h>
#include <progind.h>
#include <sort.h>
#include <urldefid.h>
#include <utility.h>
#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;
}

View File

@ -4,24 +4,18 @@
// fv 21-1-94
// ------------------------------------------------------------
#include <config.h>
#include <os_dep.h>
#include <progind.h>
#include <sheet.h>
#include <config.h>
#include <utility.h>
#include "cg4300.h"
#include <nditte.h>
#include <attiv.h>
#include <tab1100.h>
#include <mov.h>
#include <pconti.h>
#include "cg4300.h"
#ifdef DBG
#if XVT_OS == XVT_OS_WIN
#define STRICT
#include <windows.h>
#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();

View File

@ -1,12 +1,33 @@
// *******************
// Stampa registri IVA
// *******************
#include <defmask.h>
#include <execp.h>
#include <mailbox.h>
#include <prefix.h>
#include <progind.h>
#include <sheet.h>
#include <tabutil.h>
#include <utility.h>
#include "cg4.h"
#include "cg4400.h"
#include "cg4400a.h"
#include "cg4400b.h"
#include "cglib01.h"
#include <nditte.h>
#include <anagr.h>
#include <comuni.h>
#include <unloc.h>
#include <mov.h>
#include <rmoviva.h>
#include <clifo.h>
#include <occas.h>
#include <causali.h>
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<mese; i++)
{
chiave = "";
TString16 m (format("%02d", i));
TString16 m; m.format("%02d", i);
chiave << _annoes << _codatt << "1" << m << tipo;
ppa.put("CODTAB", chiave);
if (ppa.read() == NOERR)
@ -2050,8 +2070,8 @@ bool CG4400_application::preprocess_page(int file, int counter)
reset_print();
int rr = 0, riga = 0;
bool intra;
TString80 comune, prov, comcf, capcf, civcf, stacf;
TString80 viacf;
TString comune, prov, comcf, capcf, civcf, stacf;
TString viacf;
TString ragsoc;
TString tipo_op = "";
@ -2090,7 +2110,7 @@ bool CG4400_application::preprocess_page(int file, int counter)
}
//TString80 nomef; nomef = t.path(); nomef << "\\" << t.name();
//if (fexist(nomef))
if (fexist(t))
if (t.exist())
{
_intesta_liq = TRUE;
//printer().footerlen(0);
@ -2373,7 +2393,7 @@ print_action CG4400_application::postprocess_page (int file, int counter)
liq_b0_settato();
if (_scelta == prosegui_stampa || _scelta == prosegui_cal_stampa)
{
if (fexist(_t))
if (_t.exist())
{
printer().formfeed();
_intesta_liq = TRUE;
@ -2469,7 +2489,10 @@ int CG4400_application::stampa_intestazione()
riga = "REGISTRO DI PROVA Data @<";
riga.right_just(_stampa_width-6);
}
riga.overwrite (format("Partita iva %s Codice fiscale %s", (const char*)_paiva, (const char*)_cofi));
TString80 tmp;
tmp.format("Partita iva %s Codice fiscale %s", (const char*)_paiva, (const char*)_cofi);
riga.overwrite(tmp);
set_header (r, riga);
return r;
@ -2703,7 +2726,7 @@ void CG4400_application::liq_b0_settato()
//TString80 nomef;
//nomef = f.path(); nomef << "\\" << f.name();
//if (fexist(nomef))
if (fexist(f))
if (f.exist())
{
printer().formfeed();
_intesta_liq = TRUE;

View File

@ -4,27 +4,8 @@
#include <isam.h>
#include <printapp.h>
#include <mask.h>
#include <tabutil.h>
#include <utility.h>
#include <urldefid.h>
#include <text.h>
#include <mailbox.h>
#include <execp.h>
#include <sheet.h>
#include <config.h>
#include <prefix.h>
#include <progind.h>
#include <nditte.h>
#include <anagr.h>
#include <comuni.h>
#include <unloc.h>
#include <mov.h>
#include <rmoviva.h>
#include <clifo.h>
#include <occas.h>
#include <causali.h>
#include "cglib03.h"
#include "cglib04.h"
enum messaggio {
no_liquidazione,

View File

@ -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);