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:
parent
a3d13d1b9f
commit
138208fcc9
@ -229,7 +229,7 @@ bool TDongle::hardlock_login(bool test_all_keys)
|
||||
_serno = data[1];
|
||||
else
|
||||
{
|
||||
if (data[0] == 0x3283) // chiave programmatori !!
|
||||
if (data[0] == 0x3283 || data[0] == 0xA3AA) // chiave programmatori !!
|
||||
{
|
||||
_type = _developer_dongle;
|
||||
_serno = 0;
|
||||
|
@ -20,9 +20,8 @@ word TExternal_app::run(
|
||||
TFilename path(_path);
|
||||
|
||||
TFilename comm_name(_path);
|
||||
int p = comm_name.find(' ');
|
||||
|
||||
if (p >=0)
|
||||
const int p = comm_name.find(' ');
|
||||
if (p >= 0)
|
||||
comm_name.cut(p);
|
||||
|
||||
TString name(comm_name.name());
|
||||
@ -40,7 +39,6 @@ word TExternal_app::run(
|
||||
if (utente)
|
||||
path << " /u" << user();
|
||||
|
||||
_error = 0;
|
||||
_exitcode = 0;
|
||||
|
||||
// save cwd
|
||||
@ -109,10 +107,6 @@ word TExternal_app::run(
|
||||
// restore cwd
|
||||
xvt_fsys_restore_dir();
|
||||
|
||||
// update counts
|
||||
if (_exitcode == 0)
|
||||
_count++;
|
||||
|
||||
// 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
|
||||
// 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)
|
||||
: _path(p), _exitcode(0)
|
||||
{
|
||||
_path = p;
|
||||
_count = 0;
|
||||
_error = 0;
|
||||
_exitcode = 0;
|
||||
}
|
||||
|
||||
|
@ -23,30 +23,28 @@ class TExternal_app : public TObject
|
||||
{
|
||||
|
||||
// @cmember:(INTERNAL) Nome dell'applicazione (deve essere allocata dall'utente)
|
||||
const char* _path;
|
||||
// @cmember:(INTERNAL) Ultimo errore (codice dell'errore)
|
||||
int _error;
|
||||
TFilename _path;
|
||||
// @cmember:(INTERNAL) Ultimo exit code
|
||||
int _exitcode;
|
||||
// @cmember:(INTERNAL) Numero di chiamate
|
||||
int _count;
|
||||
|
||||
protected:
|
||||
void copy(const TExternal_app& a) { _path = a._path; _exitcode = 0; }
|
||||
|
||||
// @access Public Member
|
||||
public:
|
||||
// @cmember Esegue il processo
|
||||
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
|
||||
int exitcode()
|
||||
{ return _exitcode; }
|
||||
// @cmember Ritorna il numero di chiamate effettuate
|
||||
int count()
|
||||
{ return _count; }
|
||||
|
||||
const TExternal_app& operator = (const TExternal_app& a)
|
||||
{ copy(a); return a; }
|
||||
|
||||
// @cmember Costruttore
|
||||
TExternal_app(const char* p);
|
||||
TExternal_app(const TExternal_app& a) { copy(a); }
|
||||
virtual ~TExternal_app() { }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -52,26 +52,6 @@ typedef char TKey[MaxArray + 2];
|
||||
typedef char AreaKey[AreaLen];
|
||||
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 {
|
||||
int F;
|
||||
FILE* Fd;
|
||||
|
@ -230,10 +230,10 @@ public:
|
||||
{ return _rec->NKeys; }
|
||||
// @cmember Assegna il numero di campi del tracciato record
|
||||
void set_fields(int nfields)
|
||||
{ _rec->NFields = nfields;}
|
||||
{ _rec->NFields = short(nfields);}
|
||||
// @cmember Assegna il numero di chiavi di ordinamento del tracciato record
|
||||
void set_keys(int nkeys)
|
||||
{ _rec->NKeys = nkeys;}
|
||||
{ _rec->NKeys = short(nkeys);}
|
||||
// @cmember Ritorna una token string contenente la descrizione del campo
|
||||
const char* fielddef(int fld) const;
|
||||
// @cmember Ritorna una stringa contenente la chiave
|
||||
|
129
include/isam.cpp
129
include/isam.cpp
@ -20,14 +20,6 @@
|
||||
#include <codeb.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 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 } ;
|
||||
// Codici da 10 a ...
|
||||
|
||||
extern "C" {
|
||||
void CUpString(char*);
|
||||
void crtrim(char*);
|
||||
};
|
||||
|
||||
HIDDEN char _isam_string[257];
|
||||
|
||||
#define NOALLOC (char **) -1
|
||||
@ -64,7 +51,6 @@ HIDDEN bool __autoload = TRUE;
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int hashfun(const char *s)
|
||||
|
||||
{
|
||||
int l = strlen(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)
|
||||
|
||||
{
|
||||
short stp = hashfun(s);
|
||||
|
||||
@ -747,33 +732,13 @@ TExtrectype::TExtrectype(const TTrec& r) : TVariable_rectype(r.num())
|
||||
// TBaseisamfile
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TBaseisamfile::TBaseisamfile(int logicnum, bool linkrecinst)
|
||||
TBaseisamfile::TBaseisamfile(int logicnum)
|
||||
|
||||
{
|
||||
_isamfile = NULL;
|
||||
_logicnum = logicnum;
|
||||
_lasterr = NOERR;
|
||||
_delopenrec = FALSE;
|
||||
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;
|
||||
_current = new TRectype(this);
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
@ -789,7 +754,6 @@ TBaseisamfile::TBaseisamfile(
|
||||
{
|
||||
_isamfile = NULL;
|
||||
_lasterr = NOERR;
|
||||
_delopenrec = FALSE;
|
||||
_logicnum = -1;
|
||||
TFilename n(name);
|
||||
CHECK(n.not_empty(),"Must define the file to open!");
|
||||
@ -820,19 +784,12 @@ TBaseisamfile::TBaseisamfile(
|
||||
if (_logicnum == -1)
|
||||
fatal_box("Raggiunto il numero massimo di files esterni apribili.");
|
||||
_current = new TRectype(this);
|
||||
_delrec = TRUE;
|
||||
_historicfile = FALSE;
|
||||
}
|
||||
|
||||
TBaseisamfile::~TBaseisamfile()
|
||||
|
||||
{
|
||||
if (_delrec)
|
||||
{
|
||||
if (_delopenrec)
|
||||
openrec[_logicnum - 1] = NULL;
|
||||
if (_current)
|
||||
delete _current;
|
||||
}
|
||||
if (_isamfile != NULL)
|
||||
delete _isamfile;
|
||||
}
|
||||
@ -1274,8 +1231,6 @@ int TBaseisamfile::remove()
|
||||
return TBaseisamfile::remove(curr());
|
||||
}
|
||||
|
||||
|
||||
|
||||
int TBaseisamfile::lock()
|
||||
{
|
||||
NOT_OPEN();
|
||||
@ -1284,9 +1239,7 @@ int TBaseisamfile::lock()
|
||||
return _lasterr;
|
||||
}
|
||||
|
||||
|
||||
int TBaseisamfile::unlock()
|
||||
|
||||
int TBaseisamfile::unlock()
|
||||
{
|
||||
NOT_OPEN();
|
||||
_lasterr = DB_unlock(_isamfile->fhnd);
|
||||
@ -1294,21 +1247,16 @@ int TBaseisamfile::unlock()
|
||||
return (_lasterr);
|
||||
}
|
||||
|
||||
|
||||
void TBaseisamfile::indexon()
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool TBaseisamfile::empty()
|
||||
|
||||
{
|
||||
return (DB_reccount(_isamfile->fhnd) == 0);
|
||||
}
|
||||
|
||||
void TBaseisamfile::indexoff()
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
@ -1514,28 +1462,14 @@ int TBaseisamfile::is_valid()
|
||||
//
|
||||
// @rdesc Ritorna l'oggetto <c TLocalisamfile>
|
||||
TLocalisamfile::TLocalisamfile(
|
||||
int logicnum, // @parm Numero del logico del file
|
||||
byte linkrecinst) // @parm Puo assumere i valori:
|
||||
//
|
||||
// @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
|
||||
|
||||
int logicnum) // @parm Numero del logico del file
|
||||
: TBaseisamfile(logicnum)
|
||||
{
|
||||
if (linkrecinst <= TRUE)
|
||||
{
|
||||
if (open() != NOERR)
|
||||
fatal_box("Impossibile aprire il file %d", logicnum);
|
||||
if (_was_open)
|
||||
_oldkey = getkey();
|
||||
setkey(1);
|
||||
}
|
||||
else _was_open = TRUE;
|
||||
if (open() != NOERR)
|
||||
fatal_box("Impossibile aprire il file %d", logicnum);
|
||||
if (_was_open)
|
||||
_oldkey = getkey();
|
||||
setkey(1);
|
||||
}
|
||||
|
||||
// @mfunc Costruttore
|
||||
@ -1548,6 +1482,14 @@ TLocalisamfile::TLocalisamfile(
|
||||
_was_open = FALSE;
|
||||
}
|
||||
|
||||
TLocalisamfile::TLocalisamfile(int logicnum, bool tmpfile)
|
||||
: TBaseisamfile(logicnum)
|
||||
{
|
||||
CHECK(tmpfile = TRUE, "Protected constructor badly used");
|
||||
_was_open = TRUE;
|
||||
}
|
||||
|
||||
|
||||
TLocalisamfile::~TLocalisamfile()
|
||||
{
|
||||
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()
|
||||
@ -1693,7 +1637,7 @@ int TIsamfile::flags(
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TIsamtempfile::TIsamtempfile(int logicnum, const char* radix, bool create, bool autodel)
|
||||
: TLocalisamfile(logicnum, 2)
|
||||
: TLocalisamfile(logicnum, TRUE)
|
||||
{
|
||||
TRecnotype eod = 0;
|
||||
TRecnotype eox = 100;
|
||||
@ -1781,7 +1725,7 @@ int TIsamtempfile::open(
|
||||
{
|
||||
err = get_error(err);
|
||||
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
|
||||
@ -1970,8 +1914,7 @@ int TSystemisamfile::build(TRecnotype eox, const TTrec& r)
|
||||
#ifndef FOXPRO
|
||||
if (err == NOERR && __autoload)
|
||||
{
|
||||
TFilename lf;
|
||||
|
||||
TFilename lf;
|
||||
lf.format("%sstd/lf%04d.txt", __ptprf, num());
|
||||
if (fexist(lf))
|
||||
load(lf, '|', '\0', '\n', TRUE, TRUE);
|
||||
@ -2041,7 +1984,7 @@ int TSystemisamfile::exec_convapp(
|
||||
else flev++;
|
||||
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);
|
||||
|
||||
if (!conv.new_paragraph() && conv.exist(v, num()))
|
||||
@ -2053,8 +1996,7 @@ int TSystemisamfile::exec_convapp(
|
||||
TExternal_app app(s);
|
||||
if (f.exist())
|
||||
{
|
||||
app.run(FALSE, 0x3); // Synchronous Spawn with User
|
||||
err = app.error();
|
||||
err = app.run(FALSE, 0x3); // Synchronous Spawn with User
|
||||
TMailbox mail;
|
||||
TMessage* msg = mail.next(TRUE);
|
||||
if (err == 0 && msg != NULL)
|
||||
@ -2454,8 +2396,11 @@ int TSystemisamfile::load(
|
||||
if (open_now)
|
||||
{
|
||||
err = open_ex(_excllock);
|
||||
setstatus(err);
|
||||
return err;
|
||||
if (err != NOERR)
|
||||
{
|
||||
setstatus(err);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
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++)
|
||||
{
|
||||
fld.add(TString(curr().fieldname(j)), j);
|
||||
fld.add(curr().fieldname(j), j);
|
||||
const TString & wfld = (const TString & ) fld[j];
|
||||
len[j] = (curr().type(wfld) == _datefld) ? 10 : curr().length(wfld);
|
||||
}
|
||||
@ -2518,7 +2465,7 @@ int TSystemisamfile::load(
|
||||
|
||||
if (!f.paragraph("Data"))
|
||||
{
|
||||
error_box("Formato dei dati non valido");
|
||||
error_box("Formato file non valido: manca il paragrafo [Data]");
|
||||
close();
|
||||
err = 1;
|
||||
setstatus(err);
|
||||
|
@ -293,20 +293,8 @@ class TBaseisamfile : public TObject
|
||||
int _logicnum;
|
||||
// @cmember:(INTERNAL) Ultimo errore
|
||||
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
|
||||
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
|
||||
TRecnotype _recno;
|
||||
// @cmember:(INTERNAL) Indica se il file possiede dei campi memo
|
||||
@ -537,7 +525,7 @@ public:
|
||||
{ return curr() = rec;}
|
||||
|
||||
// @cmember Costruttore
|
||||
TBaseisamfile(int logicnum, bool linkrecinst = FALSE);
|
||||
TBaseisamfile(int logicnum);
|
||||
// @cmember Distruttore
|
||||
virtual ~TBaseisamfile();
|
||||
};
|
||||
@ -567,7 +555,7 @@ public:
|
||||
int close()
|
||||
{ return _close();}
|
||||
// @cmember Costruttore
|
||||
TIsamfile(int logicnum, bool linkrecinst);
|
||||
TIsamfile(int logicnum);
|
||||
// @cmember Distruttore
|
||||
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);
|
||||
|
||||
// @cmember Costruttore
|
||||
TSystemisamfile(int logicnum, bool linkrecinst = FALSE): TIsamfile(logicnum, linkrecinst)
|
||||
TSystemisamfile(int logicnum): TIsamfile(logicnum)
|
||||
{}
|
||||
// @cmember Distruttore
|
||||
virtual ~TSystemisamfile()
|
||||
@ -654,6 +642,9 @@ protected:
|
||||
int open(unsigned int mode = _manulock);
|
||||
// @cmember Chiude il file aperto
|
||||
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>).
|
||||
TLocalisamfile(const char* name);
|
||||
|
||||
@ -671,9 +662,8 @@ public:
|
||||
virtual bool tab() const
|
||||
{ return FALSE;}
|
||||
|
||||
// @cmember Costruttore. <p Linkrecinst> dice se il file deve utilizzare un area record
|
||||
// separata oppure la stessa.
|
||||
TLocalisamfile(int logicnum, byte linkrecinst = FALSE);
|
||||
// @cmember Costruttore.
|
||||
TLocalisamfile(int logicnum);
|
||||
// @cmember Distruttore
|
||||
virtual ~TLocalisamfile();
|
||||
};
|
||||
@ -845,15 +835,7 @@ for (int _e##isamfile = isamfile.first(); \
|
||||
_e##isamfile = isamfile.next())
|
||||
|
||||
|
||||
#ifdef __ISAM_CPP
|
||||
#define extern
|
||||
#endif
|
||||
|
||||
extern TRectype** openrec;
|
||||
extern void get_idx_names(int logicnum, TToken_string& i_names);
|
||||
|
||||
#undef extern
|
||||
|
||||
void get_idx_names(int logicnum, TToken_string& i_names);
|
||||
void set_autoload_new_files(bool on);
|
||||
|
||||
#endif // __ISAM_
|
||||
|
Loading…
x
Reference in New Issue
Block a user