dongle.cpp Migliorato riconoscimento delle chiavi programmatore

execp.*      Corretta gestione nomi ed errori della classe TExternal_app
extctype.h   Tolte struct inutili usate da campo
files.h      Tolte variabili inutili usate da campo
isam.cpp     Corretta ricezione files di testo
isam.h       Tolti flags di linkrecinst


git-svn-id: svn://10.65.10.50/trunk@6349 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1998-03-13 10:25:37 +00:00
parent a3d13d1b9f
commit 138208fcc9
7 changed files with 62 additions and 164 deletions

View File

@ -229,7 +229,7 @@ bool TDongle::hardlock_login(bool test_all_keys)
_serno = data[1]; _serno = data[1];
else else
{ {
if (data[0] == 0x3283) // chiave programmatori !! if (data[0] == 0x3283 || data[0] == 0xA3AA) // chiave programmatori !!
{ {
_type = _developer_dongle; _type = _developer_dongle;
_serno = 0; _serno = 0;

View File

@ -20,9 +20,8 @@ word TExternal_app::run(
TFilename path(_path); TFilename path(_path);
TFilename comm_name(_path); TFilename comm_name(_path);
int p = comm_name.find(' '); const int p = comm_name.find(' ');
if (p >= 0)
if (p >=0)
comm_name.cut(p); comm_name.cut(p);
TString name(comm_name.name()); TString name(comm_name.name());
@ -40,7 +39,6 @@ word TExternal_app::run(
if (utente) if (utente)
path << " /u" << user(); path << " /u" << user();
_error = 0;
_exitcode = 0; _exitcode = 0;
// save cwd // save cwd
@ -109,10 +107,6 @@ word TExternal_app::run(
// restore cwd // restore cwd
xvt_fsys_restore_dir(); xvt_fsys_restore_dir();
// update counts
if (_exitcode == 0)
_count++;
// Ignora volutamente il return code da HL_LOGIN(). Se va bene riprende il posto // Ignora volutamente il return code da HL_LOGIN(). Se va bene riprende il posto
// altrimenti fa lo stesso. Infatti puo' capitare con una chiave di rete, che // altrimenti fa lo stesso. Infatti puo' capitare con una chiave di rete, che
// nel lasso di tempo trascorso dalla HL_LOGOUT() dell'applicazione chiamata, // nel lasso di tempo trascorso dalla HL_LOGOUT() dell'applicazione chiamata,
@ -129,10 +123,7 @@ word TExternal_app::run(
} }
TExternal_app::TExternal_app(const char* p) TExternal_app::TExternal_app(const char* p)
: _path(p), _exitcode(0)
{ {
_path = p;
_count = 0;
_error = 0;
_exitcode = 0;
} }

View File

@ -23,30 +23,28 @@ class TExternal_app : public TObject
{ {
// @cmember:(INTERNAL) Nome dell'applicazione (deve essere allocata dall'utente) // @cmember:(INTERNAL) Nome dell'applicazione (deve essere allocata dall'utente)
const char* _path; TFilename _path;
// @cmember:(INTERNAL) Ultimo errore (codice dell'errore)
int _error;
// @cmember:(INTERNAL) Ultimo exit code // @cmember:(INTERNAL) Ultimo exit code
int _exitcode; int _exitcode;
// @cmember:(INTERNAL) Numero di chiamate
int _count; protected:
void copy(const TExternal_app& a) { _path = a._path; _exitcode = 0; }
// @access Public Member // @access Public Member
public: public:
// @cmember Esegue il processo // @cmember Esegue il processo
word run(bool async = FALSE, byte user = TRUE, bool iconize = TRUE, bool show = TRUE); word run(bool async = FALSE, byte user = TRUE, bool iconize = TRUE, bool show = TRUE);
// @cmember Ritorna il codice dell'ultimo errore
int error()
{ return _error; }
// @cmember Ritorna l'ultimo codice di uscita // @cmember Ritorna l'ultimo codice di uscita
int exitcode() int exitcode()
{ return _exitcode; } { return _exitcode; }
// @cmember Ritorna il numero di chiamate effettuate
int count() const TExternal_app& operator = (const TExternal_app& a)
{ return _count; } { copy(a); return a; }
// @cmember Costruttore // @cmember Costruttore
TExternal_app(const char* p); TExternal_app(const char* p);
TExternal_app(const TExternal_app& a) { copy(a); }
virtual ~TExternal_app() { }
}; };
#endif #endif

View File

@ -52,26 +52,6 @@ typedef char TKey[MaxArray + 2];
typedef char AreaKey[AreaLen]; typedef char AreaKey[AreaLen];
typedef char DataArea[BPageLen]; typedef char DataArea[BPageLen];
/*
typedef struct {
char nome[52] __PACKED__ ;
char indirizzo[32] __PACKED__ ;
char citta[32] __PACKED__ ;
char cap[6] __PACKED__ ;
char partiva[12] __PACKED__ ;
char codfisc[18] __PACKED__ ;
short numero __PACKED__ ;
short tab0[20] __PACKED__ ;
long tab1 __PACKED__ ;
char nome1[52] __PACKED__ ;
char indirizzo1[32] __PACKED__ ;
char citta1[32] __PACKED__ ;
char cap1[6] __PACKED__ ;
char partiva1[12] __PACKED__ ;
char codfisc1[18] __PACKED__ ;
} TDitta;
*/
typedef struct { typedef struct {
int F; int F;
FILE* Fd; FILE* Fd;

View File

@ -230,10 +230,10 @@ public:
{ return _rec->NKeys; } { return _rec->NKeys; }
// @cmember Assegna il numero di campi del tracciato record // @cmember Assegna il numero di campi del tracciato record
void set_fields(int nfields) void set_fields(int nfields)
{ _rec->NFields = nfields;} { _rec->NFields = short(nfields);}
// @cmember Assegna il numero di chiavi di ordinamento del tracciato record // @cmember Assegna il numero di chiavi di ordinamento del tracciato record
void set_keys(int nkeys) void set_keys(int nkeys)
{ _rec->NKeys = nkeys;} { _rec->NKeys = short(nkeys);}
// @cmember Ritorna una token string contenente la descrizione del campo // @cmember Ritorna una token string contenente la descrizione del campo
const char* fielddef(int fld) const; const char* fielddef(int fld) const;
// @cmember Ritorna una stringa contenente la chiave // @cmember Ritorna una stringa contenente la chiave

View File

@ -20,14 +20,6 @@
#include <codeb.h> #include <codeb.h>
#include <varrec.h> #include <varrec.h>
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
#include <process.h>
#else
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#endif
#define NOT_OPEN() CHECKS(_isamfile != NULL, "File chiuso: ", (const char*)name()) #define NOT_OPEN() CHECKS(_isamfile != NULL, "File chiuso: ", (const char*)name())
#define RECLOCKTYPES 0xFF00 #define RECLOCKTYPES 0xFF00
@ -46,11 +38,6 @@ HIDDEN int error_codes_ra[] = {NOERR,NOERR,_iskeynotfound,_iseof,_isbof,_isnrece
HIDDEN int error_codes_rb[] = {-1,-1,_isreinsert,-1,-1,_islocked,-1,_isalropen,_iskeyerr } ; HIDDEN int error_codes_rb[] = {-1,-1,_isreinsert,-1,-1,_islocked,-1,_isalropen,_iskeyerr } ;
// Codici da 10 a ... // Codici da 10 a ...
extern "C" {
void CUpString(char*);
void crtrim(char*);
};
HIDDEN char _isam_string[257]; HIDDEN char _isam_string[257];
#define NOALLOC (char **) -1 #define NOALLOC (char **) -1
@ -64,7 +51,6 @@ HIDDEN bool __autoload = TRUE;
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
int hashfun(const char *s) int hashfun(const char *s)
{ {
int l = strlen(s); int l = strlen(s);
unsigned short temp = 0, *pw = (unsigned short *) s; unsigned short temp = 0, *pw = (unsigned short *) s;
@ -83,7 +69,6 @@ int hashfun(const char *s)
} }
int findfld(const RecDes *recd, const char *s) int findfld(const RecDes *recd, const char *s)
{ {
short stp = hashfun(s); short stp = hashfun(s);
@ -747,33 +732,13 @@ TExtrectype::TExtrectype(const TTrec& r) : TVariable_rectype(r.num())
// TBaseisamfile // TBaseisamfile
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
TBaseisamfile::TBaseisamfile(int logicnum, bool linkrecinst) TBaseisamfile::TBaseisamfile(int logicnum)
{ {
_isamfile = NULL; _isamfile = NULL;
_logicnum = logicnum; _logicnum = logicnum;
_lasterr = NOERR; _lasterr = NOERR;
_delopenrec = FALSE; _current = new TRectype(this);
if ((openrec[_logicnum - 1] == NULL) || (!linkrecinst))
{
_current = new TRectype(this);
if (openrec[_logicnum - 1] == NULL)
{
openrec[_logicnum - 1] = _current;
_delopenrec = TRUE;
}
_delrec = TRUE;
}
else
{
NFCHECK("linkrecinst sparira' quanto prima, poiche' non sicura");
_current = openrec[_logicnum - 1];
_delrec = FALSE;
}
// _historicfile = ((r.field(RFLD_SYS_DATE) != FIELDERR) &&
// (r.field(RFLD_SYS_FIRST) != FIELDERR) &&
// (r.field(RFLD_SYS_LAST) != FIELDERR));
_historicfile = FALSE;
} }
// @doc EXTERNAL // @doc EXTERNAL
@ -789,7 +754,6 @@ TBaseisamfile::TBaseisamfile(
{ {
_isamfile = NULL; _isamfile = NULL;
_lasterr = NOERR; _lasterr = NOERR;
_delopenrec = FALSE;
_logicnum = -1; _logicnum = -1;
TFilename n(name); TFilename n(name);
CHECK(n.not_empty(),"Must define the file to open!"); CHECK(n.not_empty(),"Must define the file to open!");
@ -820,19 +784,12 @@ TBaseisamfile::TBaseisamfile(
if (_logicnum == -1) if (_logicnum == -1)
fatal_box("Raggiunto il numero massimo di files esterni apribili."); fatal_box("Raggiunto il numero massimo di files esterni apribili.");
_current = new TRectype(this); _current = new TRectype(this);
_delrec = TRUE;
_historicfile = FALSE;
} }
TBaseisamfile::~TBaseisamfile() TBaseisamfile::~TBaseisamfile()
{ {
if (_delrec) if (_current)
{
if (_delopenrec)
openrec[_logicnum - 1] = NULL;
delete _current; delete _current;
}
if (_isamfile != NULL) if (_isamfile != NULL)
delete _isamfile; delete _isamfile;
} }
@ -1274,8 +1231,6 @@ int TBaseisamfile::remove()
return TBaseisamfile::remove(curr()); return TBaseisamfile::remove(curr());
} }
int TBaseisamfile::lock() int TBaseisamfile::lock()
{ {
NOT_OPEN(); NOT_OPEN();
@ -1284,9 +1239,7 @@ int TBaseisamfile::lock()
return _lasterr; return _lasterr;
} }
int TBaseisamfile::unlock()
int TBaseisamfile::unlock()
{ {
NOT_OPEN(); NOT_OPEN();
_lasterr = DB_unlock(_isamfile->fhnd); _lasterr = DB_unlock(_isamfile->fhnd);
@ -1294,21 +1247,16 @@ int TBaseisamfile::unlock()
return (_lasterr); return (_lasterr);
} }
void TBaseisamfile::indexon() void TBaseisamfile::indexon()
{ {
} }
bool TBaseisamfile::empty() bool TBaseisamfile::empty()
{ {
return (DB_reccount(_isamfile->fhnd) == 0); return (DB_reccount(_isamfile->fhnd) == 0);
} }
void TBaseisamfile::indexoff() void TBaseisamfile::indexoff()
{ {
} }
@ -1514,28 +1462,14 @@ int TBaseisamfile::is_valid()
// //
// @rdesc Ritorna l'oggetto <c TLocalisamfile> // @rdesc Ritorna l'oggetto <c TLocalisamfile>
TLocalisamfile::TLocalisamfile( TLocalisamfile::TLocalisamfile(
int logicnum, // @parm Numero del logico del file int logicnum) // @parm Numero del logico del file
byte linkrecinst) // @parm Puo assumere i valori: : TBaseisamfile(logicnum)
//
// @flag 0 | Istanzio un nuovo file fisico (default)
// @flag 1 | Utilizza, se possibile, un file gia' esistente
// @flag 2 | Crea un file temporaneo
: TBaseisamfile(logicnum, linkrecinst == TRUE)
// @comm ATTENZIONE: <p linkrecinst> puo' valere 0, 1, 2.
// Se vale 2 significa che si sta costruendo un file temporaneo
// per cui linkrecinst va' considerato FALSE
{ {
if (linkrecinst <= TRUE) if (open() != NOERR)
{ fatal_box("Impossibile aprire il file %d", logicnum);
if (open() != NOERR) if (_was_open)
fatal_box("Impossibile aprire il file %d", logicnum); _oldkey = getkey();
if (_was_open) setkey(1);
_oldkey = getkey();
setkey(1);
}
else _was_open = TRUE;
} }
// @mfunc Costruttore // @mfunc Costruttore
@ -1548,6 +1482,14 @@ TLocalisamfile::TLocalisamfile(
_was_open = FALSE; _was_open = FALSE;
} }
TLocalisamfile::TLocalisamfile(int logicnum, bool tmpfile)
: TBaseisamfile(logicnum)
{
CHECK(tmpfile = TRUE, "Protected constructor badly used");
_was_open = TRUE;
}
TLocalisamfile::~TLocalisamfile() TLocalisamfile::~TLocalisamfile()
{ {
if (_isamfile) if (_isamfile)
@ -1649,7 +1591,9 @@ int TLocalisamfile::operator --()
TIsamfile::TIsamfile(int logicnum, bool linkrecinst) : TBaseisamfile(logicnum, linkrecinst) {} TIsamfile::TIsamfile(int logicnum)
: TBaseisamfile(logicnum)
{ }
TIsamfile::~TIsamfile() TIsamfile::~TIsamfile()
@ -1693,7 +1637,7 @@ int TIsamfile::flags(
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
TIsamtempfile::TIsamtempfile(int logicnum, const char* radix, bool create, bool autodel) TIsamtempfile::TIsamtempfile(int logicnum, const char* radix, bool create, bool autodel)
: TLocalisamfile(logicnum, 2) : TLocalisamfile(logicnum, TRUE)
{ {
TRecnotype eod = 0; TRecnotype eod = 0;
TRecnotype eox = 100; TRecnotype eox = 100;
@ -1781,7 +1725,7 @@ int TIsamtempfile::open(
{ {
err = get_error(err); err = get_error(err);
relisfd(_isamfile); relisfd(_isamfile);
fatal_box("Create temporary file: Error n. %d", err); fatal_box("Can't create temp file '%s': Error n. %d", (const char*)tmpname, err);
} }
} }
else else
@ -1970,8 +1914,7 @@ int TSystemisamfile::build(TRecnotype eox, const TTrec& r)
#ifndef FOXPRO #ifndef FOXPRO
if (err == NOERR && __autoload) if (err == NOERR && __autoload)
{ {
TFilename lf; TFilename lf;
lf.format("%sstd/lf%04d.txt", __ptprf, num()); lf.format("%sstd/lf%04d.txt", __ptprf, num());
if (fexist(lf)) if (fexist(lf))
load(lf, '|', '\0', '\n', TRUE, TRUE); load(lf, '|', '\0', '\n', TRUE, TRUE);
@ -2041,7 +1984,7 @@ int TSystemisamfile::exec_convapp(
else flev++; else flev++;
for (long l = flev; err == 0 && l <= get_std_level(); l++) for (long l = flev; err == 0 && l <= get_std_level(); l++)
{ {
TString16 paragraph(format("%06ld", l)); TString16 paragraph; paragraph.format("%06ld", l);
TConfig conv(CONFIG_FCONV, paragraph); TConfig conv(CONFIG_FCONV, paragraph);
if (!conv.new_paragraph() && conv.exist(v, num())) if (!conv.new_paragraph() && conv.exist(v, num()))
@ -2053,8 +1996,7 @@ int TSystemisamfile::exec_convapp(
TExternal_app app(s); TExternal_app app(s);
if (f.exist()) if (f.exist())
{ {
app.run(FALSE, 0x3); // Synchronous Spawn with User err = app.run(FALSE, 0x3); // Synchronous Spawn with User
err = app.error();
TMailbox mail; TMailbox mail;
TMessage* msg = mail.next(TRUE); TMessage* msg = mail.next(TRUE);
if (err == 0 && msg != NULL) if (err == 0 && msg != NULL)
@ -2454,8 +2396,11 @@ int TSystemisamfile::load(
if (open_now) if (open_now)
{ {
err = open_ex(_excllock); err = open_ex(_excllock);
setstatus(err); if (err != NOERR)
return err; {
setstatus(err);
return err;
}
} }
TScanner f(from); TScanner f(from);
@ -2506,11 +2451,13 @@ int TSystemisamfile::load(
} }
} }
} }
else
{ if (nflds == 0 || fld.items() == 0)
{
nflds = curr().items();
for (int j = 0; j < nflds; j++) for (int j = 0; j < nflds; j++)
{ {
fld.add(TString(curr().fieldname(j)), j); fld.add(curr().fieldname(j), j);
const TString & wfld = (const TString & ) fld[j]; const TString & wfld = (const TString & ) fld[j];
len[j] = (curr().type(wfld) == _datefld) ? 10 : curr().length(wfld); len[j] = (curr().type(wfld) == _datefld) ? 10 : curr().length(wfld);
} }
@ -2518,7 +2465,7 @@ int TSystemisamfile::load(
if (!f.paragraph("Data")) if (!f.paragraph("Data"))
{ {
error_box("Formato dei dati non valido"); error_box("Formato file non valido: manca il paragrafo [Data]");
close(); close();
err = 1; err = 1;
setstatus(err); setstatus(err);

View File

@ -293,20 +293,8 @@ class TBaseisamfile : public TObject
int _logicnum; int _logicnum;
// @cmember:(INTERNAL) Ultimo errore // @cmember:(INTERNAL) Ultimo errore
int _lasterr; int _lasterr;
// @cmember:(INTERNAL) Permette di sapere se rimuovere il record alla fine
bool _delrec;
// @cmember:(INTERNAL) Permette di sapere se rimuovere il record alla fine dalla lista interna di record
bool _delopenrec;
// @cmember:(INTERNAL) Puntatore a record corrente // @cmember:(INTERNAL) Puntatore a record corrente
TRectype* _current; TRectype* _current;
// @cmember:(INTERNAL) UNUSED
TFile _hf;
// @cmember:(INTERNAL) UNUSED
TFile _hfhd;
// @cmember:(INTERNAL) Indica se il file e' archivio storico
bool _historicfile;
// @cmember:(INTERNAL) UNUSED
TRecnotype _lasthf;
// @cmember:(INTERNAL) Record corrente // @cmember:(INTERNAL) Record corrente
TRecnotype _recno; TRecnotype _recno;
// @cmember:(INTERNAL) Indica se il file possiede dei campi memo // @cmember:(INTERNAL) Indica se il file possiede dei campi memo
@ -537,7 +525,7 @@ public:
{ return curr() = rec;} { return curr() = rec;}
// @cmember Costruttore // @cmember Costruttore
TBaseisamfile(int logicnum, bool linkrecinst = FALSE); TBaseisamfile(int logicnum);
// @cmember Distruttore // @cmember Distruttore
virtual ~TBaseisamfile(); virtual ~TBaseisamfile();
}; };
@ -567,7 +555,7 @@ public:
int close() int close()
{ return _close();} { return _close();}
// @cmember Costruttore // @cmember Costruttore
TIsamfile(int logicnum, bool linkrecinst); TIsamfile(int logicnum);
// @cmember Distruttore // @cmember Distruttore
virtual ~TIsamfile(); virtual ~TIsamfile();
}; };
@ -625,7 +613,7 @@ public:
int dump(const char* to, int nkey = 1, char fs = '|', char fd = '\0', char rs = '\n', bool vis = TRUE, bool withdeleted = FALSE); int dump(const char* to, int nkey = 1, char fs = '|', char fd = '\0', char rs = '\n', bool vis = TRUE, bool withdeleted = FALSE);
// @cmember Costruttore // @cmember Costruttore
TSystemisamfile(int logicnum, bool linkrecinst = FALSE): TIsamfile(logicnum, linkrecinst) TSystemisamfile(int logicnum): TIsamfile(logicnum)
{} {}
// @cmember Distruttore // @cmember Distruttore
virtual ~TSystemisamfile() virtual ~TSystemisamfile()
@ -654,6 +642,9 @@ protected:
int open(unsigned int mode = _manulock); int open(unsigned int mode = _manulock);
// @cmember Chiude il file aperto // @cmember Chiude il file aperto
int close() ; int close() ;
// @cmember Costruttore per derivare TTempIsamfile
TLocalisamfile(int logicnum, bool tmp);
// @cmember Costruttore per derivare TExternisamfile. <p Name> indica il file esterno da aprire (vedi <c TBaseisamfile>). // @cmember Costruttore per derivare TExternisamfile. <p Name> indica il file esterno da aprire (vedi <c TBaseisamfile>).
TLocalisamfile(const char* name); TLocalisamfile(const char* name);
@ -671,9 +662,8 @@ public:
virtual bool tab() const virtual bool tab() const
{ return FALSE;} { return FALSE;}
// @cmember Costruttore. <p Linkrecinst> dice se il file deve utilizzare un area record // @cmember Costruttore.
// separata oppure la stessa. TLocalisamfile(int logicnum);
TLocalisamfile(int logicnum, byte linkrecinst = FALSE);
// @cmember Distruttore // @cmember Distruttore
virtual ~TLocalisamfile(); virtual ~TLocalisamfile();
}; };
@ -845,15 +835,7 @@ for (int _e##isamfile = isamfile.first(); \
_e##isamfile = isamfile.next()) _e##isamfile = isamfile.next())
#ifdef __ISAM_CPP void get_idx_names(int logicnum, TToken_string& i_names);
#define extern
#endif
extern TRectype** openrec;
extern void get_idx_names(int logicnum, TToken_string& i_names);
#undef extern
void set_autoload_new_files(bool on); void set_autoload_new_files(bool on);
#endif // __ISAM_ #endif // __ISAM_