applicat.cpp Aggiunta gestione chiave di protezione di rete

codeb.c        Corretta creazione nome tag delle chiavi
isam.h         Aggiunta put dei long double
relation.cpp   Corretta rewrite delle relazioni
stack.cpp      Aggiunto metodo remove_base
stack.h        Cambita derivazione da TArray a TObject
stdtypes.cpp   Aggiunto supporto per chiave di rete
stdtypes.h     Aggiunta chiamata get_serial_number(const char* )


git-svn-id: svn://10.65.10.50/trunk@4500 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1997-06-03 13:51:20 +00:00
parent fcba93ac94
commit f9b9e70dbd
8 changed files with 107 additions and 46 deletions

View File

@ -394,7 +394,6 @@ const char* TApplication::get_module_name() const
void TApplication::set_perms()
{
CGetAut(1);
_dongle_aut.set(0, TRUE);
for (int i = 1 ; i < ENDAUT; i++)
{
@ -486,18 +485,18 @@ void TApplication::run(
_name = cmd2name(argv[0]);
}
const int sn = get_serial_number();
if (use_files())
init_global_vars();
else
CGetPref();
const int sn = get_serial_number(firm_change_enabled() ? _name : "ba0100");
if (sn < 0)
{
error_box("Perhaps you forgot to connect the dongle");
return;
}
if (use_files())
init_global_vars();
else
CGetPref();
set_perms();
const TFixed_string mod(get_module_name());

View File

@ -360,10 +360,12 @@ int DB_bof(int handle)
/*-------------------------------------------------------------------------
legge un record per numero record
--------------------------------------------------------------------------*/
int DB_go(int handle,long int recno)
int DB_go(int handle,long recno)
{
if(dbdata[handle]==0) return(-1);
return(x4go(&xdb[handle],recno));
if (dbdata[handle] == 0)
return(-1);
// return x4go(&xdb[handle],recno);
return d4go(dbdata[handle], recno);
}
/*-------------------------------------------------------------------------
@ -567,8 +569,11 @@ HIDDEN void do_key(char *fname, RecDes *r, TAG4INFO *tag_info, int n_keys)
{
int i,j;
char tiname[9]; /* Tag name, max 8 characters long! */
char* dot;
strcpy(tiname,fname);
dot = strchr(tiname, '.');
if (dot) *dot = '\0';
CUpString(tiname);
for (i=0; ((i < MaxKeys) && (i < n_keys)); i++)
{

View File

@ -215,6 +215,12 @@ public:
void put(const char* fieldname, const char* val) { put_str(fieldname, val); }
#endif
#ifdef __LONGDOUBLE__
// @cmember Setta il contenuto del campo <p fieldname> in formato reale
void put(const char* fieldname, long double val)
{ put(fieldname, real(val)); }
#endif
// @cmember Vuota il campo puntato da <p fieldname>
virtual void zero(const char * fieldname);
// @cmember Vuota tutto il record usando il carattere <p c>
@ -512,6 +518,12 @@ public:
{ return (const char *) curr().get_str(fieldname);}
#endif
#ifdef __LONGDOUBLE__
// @cmember Setta il contenuto del campo <p fieldname> in formato reale
void put(const char* fieldname, long double val)
{ curr().put(fieldname, real(val)); }
#endif
// @cmember Setta il contenuto del campo <p fieldname> (non tipizzata)
void put(const char* fieldname, const char* val)
{ curr().put(fieldname, val);}

View File

@ -856,9 +856,10 @@ int TRelation::rewrite(bool force)
continue;
int res = lf.rewrite();
if (force && res == _iskeynotfound)
if (force && (res == _iskeynotfound || res == _iseof || res == _isemptyfile))
res = lf.write();
if (_errors == NOERR) _errors = res;
if (_errors == NOERR)
_errors = res;
}
return _errors;

View File

@ -1,26 +1,31 @@
#include <stack.h>
TStack::TStack(int size) : TArray(size), _sp(0)
TStack::TStack(int size) : _data(size), _sp(0)
{}
void TStack::push(const TObject& o)
{
add(o, _sp++);
_data.add(o, _sp++);
}
void TStack::push(TObject* o)
{
add(o, _sp++);
_data.add(o, _sp++);
}
TObject& TStack::pop()
{
CHECK(_sp > 0, "Stack underflow!");
return (*this)[--_sp];
return _data[--_sp];
}
TObject& TStack::peek(int depth) const
{
CHECKD(depth >= 0 && depth < _sp, "Stack depth error: ", depth);
return (*this)[_sp-depth-1];
return _data[_sp-depth-1];
}
bool TStack::destroy_base()
{
return _data.destroy(0, TRUE);
}

View File

@ -9,13 +9,15 @@
// @class TStack | Classe per la gestione dello stack a basso livello
//
// @base public | TArray
class TStack : private TArray
// @base public | TObject
class TStack : public TObject
// @author:(INTERNAL) Alex
// @access:(INTERNAL) Private Member
{
// @cmember:(INTERNAL) Dati dello stack
TArray _data;
// @cmember:(INTERNAL) Puntatore alla cima dello stack
int _sp;
@ -32,6 +34,8 @@ public:
TObject& pop();
// @cmember Ritorna l'oggetto ad una data profondita' nello stack
TObject& peek(int depth = 0) const;
// @cmember Distrugge l'oggetto alla base dello stack
bool destroy_base();
// @cmember Costruttore. Chiama il costruttore di <c TArray>
TStack(int size = 16);
// @cmember Distruttore. Chiama il distruttore di <c TArray>

View File

@ -6,13 +6,14 @@
#include <extcdecl.h>
#include <conf.h>
#include <modaut.h>
#include <isamrpc.h>
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
#include <dos.h>
#include <hlapi_c.h>
#endif
#include <checks.h>
#include <applicat.h>
#include <isam.h>
#include <prefix.h>
#include <codeb.h>
@ -28,17 +29,51 @@ long get_std_level()
// @doc INTERNAL
static int _login_status = 0;
// @func Ritorna il numero di serie della chiave
//
// @rdesc Numero di serie della chiave
int get_serial_number()
int get_serial_number(const char* appname)
{
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
const int status = HL_LOGIN(ModAd, DONT_CARE, REFKEY, VERKEY);
if (status != STATUS_OK)
return -1;
#endif
return getser();
if (_login_status == 0)
{
if (HL_LOGIN(ModAd, DONT_CARE, REFKEY, VERKEY) == STATUS_OK)
{
_login_status = 1;
getser();
}
}
if (_login_status != 1)
{
if (_login_status == 2)
{
rpc_UserLogout();
SerNo = 0xFFFF;
}
TConfig ini(CONFIG_STUDIO, "Server");
const char* server = ini.get("Name");
const char* guest = "******";
const char* utente = (!xvt_running() && !stricmp(appname, "ba0100")) ? guest : user();
if (rpc_UserLogin(server, utente, guest, appname))
{
_login_status = 2;
SerNo = rpc_DongleNumber();
}
else
_login_status = 0;
}
switch(_login_status)
{
case 1 : CGetAut(1) != 0; break;
case 2 : rpc_DongleModules(_int_tab0); break;
default: memset(_int_tab0, 0, sizeof(_int_tab0)); break;
}
return SerNo;
}
// @doc INTERNAL
@ -70,11 +105,6 @@ void init_global_vars()
openrec[i] = NULL;
}
#if XVT_OS == XVT_OS_SCOUNIX
const bool muflag = CGetAut(MUAUT);
if (SerNo && !muflag)
fatal_box("Abnormal termination: check protection or serial number\n");
#endif
DB_init();
}
// @doc INTERNAL
@ -83,8 +113,12 @@ void init_global_vars()
void free_global_vars()
{
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
if (_login_status == 2)
rpc_UserLogout();
else
HL_LOGOUT();
#endif
if (openf != NULL)
{
delete openf;

View File

@ -80,7 +80,8 @@ typedef UINT16 KEY;
#undef _SVID
int get_serial_number();
int get_serial_number(const char* appname);
long get_std_level();
void init_global_vars();
void free_global_vars();