Corretta formattazione

git-svn-id: svn://10.65.10.50/trunk@574 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1994-11-10 10:59:24 +00:00
parent 9a70c637c2
commit 85ed604ddd
3 changed files with 601 additions and 601 deletions

View File

@ -1,114 +1,114 @@
#include <relapp.h> #include <relapp.h>
#include <stdtypes.h> #include <stdtypes.h>
#include <modaut.h> #include <modaut.h>
#include <utility.h> #include <utility.h>
#include "ba1.h" #include "ba1.h"
#include "ba0100a.h" #include "ba0100a.h"
class TSet_users : public TRelation_application class TSet_users : public TRelation_application
{ {
TMask* _msk; TMask* _msk;
TRelation* _rel; TRelation* _rel;
virtual bool user_create() ; virtual bool user_create() ;
virtual bool user_destroy() ; virtual bool user_destroy() ;
virtual TMask* get_mask(int mode) { return _msk;} virtual TMask* get_mask(int mode) { return _msk;}
virtual bool changing_mask(int mode) { return FALSE;} virtual bool changing_mask(int mode) { return FALSE;}
virtual TRelation* get_relation() const { return _rel;} virtual TRelation* get_relation() const { return _rel;}
virtual int read(TMask& m); virtual int read(TMask& m);
virtual int write(const TMask& m); virtual int write(const TMask& m);
virtual int rewrite(const TMask& m); virtual int rewrite(const TMask& m);
void enable_aut(TMask& m); void enable_aut(TMask& m);
static bool password_handler(TMask_field& f, KEY key); static bool password_handler(TMask_field& f, KEY key);
virtual void init_query_mode(TMask& m) { enable_aut(m);} virtual void init_query_mode(TMask& m) { enable_aut(m);}
virtual void init_insert_mode(TMask& m) { enable_aut(m);} virtual void init_insert_mode(TMask& m) { enable_aut(m);}
virtual void init_modify_mode(TMask& m) { enable_aut(m);} virtual void init_modify_mode(TMask& m) { enable_aut(m);}
public: public:
TSet_users() : _msk(NULL), _rel(NULL) {} TSet_users() : _msk(NULL), _rel(NULL) {}
}; };
bool TSet_users::password_handler(TMask_field& f, KEY key) bool TSet_users::password_handler(TMask_field& f, KEY key)
{ {
if (f.mask().mode() == MODE_QUERY || key != K_ENTER) return TRUE; if (f.mask().mode() == MODE_QUERY || key != K_ENTER) return TRUE;
const bool ok = f.get().len() > 3 ; const bool ok = f.get().len() > 3 ;
if (!ok) f.error_box("La password deve essere almeno 3 caratteri"); if (!ok) f.error_box("La password deve essere almeno 3 caratteri");
return ok; return ok;
} }
void TSet_users::enable_aut(TMask& m) void TSet_users::enable_aut(TMask& m)
{ {
const bool prassi = (m.get(F_USER) == "PRASSI"); const bool prassi = (m.get(F_USER) == "PRASSI");
for (int i = 1; i < ENDAUT; i++) for (int i = 1; i < ENDAUT; i++)
{ {
if (i == MUAUT) continue; if (i == MUAUT) continue;
const int pos = _msk->id2pos(F_BASE + i); const int pos = _msk->id2pos(F_BASE + i);
if (pos >= 0) if (pos >= 0)
{ {
TMask_field& f = m.fld(pos); TMask_field& f = m.fld(pos);
f.enable(!prassi && has_module(i, CHK_DONGLE)); f.enable(!prassi && has_module(i, CHK_DONGLE));
if (prassi) f.set("X"); if (prassi) f.set("X");
} }
} }
} }
bool TSet_users::user_create() bool TSet_users::user_create()
{ {
if (user() != "PRASSI") if (user() != "PRASSI")
return error_box("Utente non abilitato all'uso di questo programma"); return error_box("Utente non abilitato all'uso di questo programma");
_msk = new TMask("ba1400a") ; _msk = new TMask("ba1400a") ;
_rel = new TRelation(LF_USER); _rel = new TRelation(LF_USER);
_msk->field(F_MU).disable(); _msk->field(F_MU).disable();
_msk->set_handler(F_PASSWORD, password_handler); _msk->set_handler(F_PASSWORD, password_handler);
return TRUE; return TRUE;
} }
int TSet_users::read(TMask& m) int TSet_users::read(TMask& m)
{ {
TRelation_application::read(m); TRelation_application::read(m);
const TRelation *r = get_relation(); const TRelation *r = get_relation();
m.set(F_PASSWORD, decode(r->lfile().get("PASSWORD"))); m.set(F_PASSWORD, decode(r->lfile().get("PASSWORD")));
return NOERR; return NOERR;
} }
int TSet_users::write(const TMask& m) int TSet_users::write(const TMask& m)
{ {
TRelation *r = get_relation(); TRelation *r = get_relation();
TString16 s(encode(m.get(F_PASSWORD))); TString16 s(encode(m.get(F_PASSWORD)));
r->lfile().put("PASSWORD", (const char *) s); r->lfile().put("PASSWORD", (const char *) s);
return TRelation_application::write(m); return TRelation_application::write(m);
} }
int TSet_users::rewrite(const TMask& m) int TSet_users::rewrite(const TMask& m)
{ {
TRelation *r = get_relation(); TRelation *r = get_relation();
TString16 s(encode(m.get(F_PASSWORD))); TString16 s(encode(m.get(F_PASSWORD)));
r->lfile().put("PASSWORD", s); r->lfile().put("PASSWORD", s);
return TRelation_application::rewrite(m); return TRelation_application::rewrite(m);
} }
bool TSet_users::user_destroy() bool TSet_users::user_destroy()
{ {
if (_msk != NULL) delete _msk; if (_msk != NULL) delete _msk;
if (_rel != NULL) delete _rel; if (_rel != NULL) delete _rel;
return TRUE; return TRUE;
} }
int ba1400(int argc, char** argv) int ba1400(int argc, char** argv)
{ {
TSet_users a ; TSet_users a ;
a.run(argc, argv, "Configurazione utenti"); a.run(argc, argv, "Configurazione utenti");
return 0; return 0;
} }

View File

@ -1,115 +1,115 @@
#include "ba0100a.h" #include "ba0100a.h"
TOOLBAR "" 0 20 0 2 TOOLBAR "" 0 20 0 2
#include <toolbar.h> #include <toolbar.h>
ENDPAGE ENDPAGE
PAGE "Gestione utenti" -1 -1 35 7 PAGE "Gestione utenti" -1 -1 35 7
STRING F_USER 8 STRING F_USER 8
BEGIN BEGIN
PROMPT 1 1 "Utente " PROMPT 1 1 "Utente "
HELP "Inserire il nome dell'utente" HELP "Inserire il nome dell'utente"
FLAGS "U" FLAGS "U"
USE LF_USER USE LF_USER
CHECKTYPE NORMAL CHECKTYPE NORMAL
INPUT USERNAME F_USER INPUT USERNAME F_USER
DISPLAY "Utente" USERNAME DISPLAY "Utente" USERNAME
DISPLAY "Descrizione@50" USERDESC DISPLAY "Descrizione@50" USERDESC
OUTPUT F_USER USERNAME OUTPUT F_USER USERNAME
KEY 1 KEY 1
CHECHTYPE REQUIRED CHECHTYPE REQUIRED
FIELD USERNAME FIELD USERNAME
END END
STRING F_USERDESC 50 STRING F_USERDESC 50
BEGIN BEGIN
PROMPT 1 3 "Descrizione " PROMPT 1 3 "Descrizione "
FIELD USERDESC FIELD USERDESC
MESSAGE "X",F_BASE MESSAGE "X",F_BASE
END END
STRING F_PASSWORD 8 0 STRING F_PASSWORD 8 0
BEGIN BEGIN
PROMPT 1 5 "Password " PROMPT 1 5 "Password "
HELP "Inserire la password" HELP "Inserire la password"
MESSAGE "X",F_BASE MESSAGE "X",F_BASE
MESSAGE "X",F_MU MESSAGE "X",F_MU
END END
GROUPBOX DLG_NULL 76 13 GROUPBOX DLG_NULL 76 13
BEGIN BEGIN
PROMPT 0 7 "Moduli" PROMPT 0 7 "Moduli"
END END
BOOLEAN F_BASE BOOLEAN F_BASE
BEGIN BEGIN
PROMPT 1 8 "Base" PROMPT 1 8 "Base"
FLAGS "D" FLAGS "D"
FIELD AUTSTR[1,1] FIELD AUTSTR[1,1]
END END
BOOLEAN F_CG BOOLEAN F_CG
BEGIN BEGIN
PROMPT 31 8 "Contabilita'" PROMPT 31 8 "Contabilita'"
FIELD AUTSTR[2,2] FIELD AUTSTR[2,2]
END END
BOOLEAN F_MU BOOLEAN F_MU
BEGIN BEGIN
PROMPT 59 8 "Multiutenza" PROMPT 59 8 "Multiutenza"
FIELD AUTSTR[3,3] FIELD AUTSTR[3,3]
FLAGS "D" FLAGS "D"
END END
BOOLEAN F_SC BOOLEAN F_SC
BEGIN BEGIN
PROMPT 1 9 "Saldaconto" PROMPT 1 9 "Saldaconto"
FIELD AUTSTR[4,4] FIELD AUTSTR[4,4]
END END
BOOLEAN F_EF BOOLEAN F_EF
BEGIN BEGIN
PROMPT 31 9 "Portafoglio" PROMPT 31 9 "Portafoglio"
FIELD AUTSTR[5,5] FIELD AUTSTR[5,5]
END END
BOOLEAN F_VE BOOLEAN F_VE
BEGIN BEGIN
PROMPT 59 9 "Vendite" PROMPT 59 9 "Vendite"
FIELD AUTSTR[6,6] FIELD AUTSTR[6,6]
END END
BOOLEAN F_MG BOOLEAN F_MG
BEGIN BEGIN
PROMPT 1 10 "Magazzino" PROMPT 1 10 "Magazzino"
FIELD AUTSTR[7,7] FIELD AUTSTR[7,7]
END END
BOOLEAN F_770 BOOLEAN F_770
BEGIN BEGIN
PROMPT 31 10 "770" PROMPT 31 10 "770"
FIELD AUTSTR[8,8] FIELD AUTSTR[8,8]
END END
BOOLEAN F_AB BOOLEAN F_AB
BEGIN BEGIN
PROMPT 59 10 "Bilanci" PROMPT 59 10 "Bilanci"
FIELD AUTSTR[21,21] FIELD AUTSTR[21,21]
END END
BOOLEAN F_NI BOOLEAN F_NI
BEGIN BEGIN
PROMPT 1 11 "Nota integrativa" PROMPT 1 11 "Nota integrativa"
FIELD AUTSTR[22,22] FIELD AUTSTR[22,22]
END END
BOOLEAN F_NR BOOLEAN F_NR
BEGIN BEGIN
PROMPT 31 11 "Nota integrativa ridotta" PROMPT 31 11 "Nota integrativa ridotta"
FIELD AUTSTR[23,23] FIELD AUTSTR[23,23]
END END
ENDPAGE ENDPAGE
ENDMASK ENDMASK

View File

@ -1,372 +1,372 @@
#include <applicat.h> #include <applicat.h>
#include <modaut.h> #include <modaut.h>
#include <mask.h> #include <mask.h>
#include <utility.h> #include <utility.h>
#include <urldefid.h> #include <urldefid.h>
#include <extcdecl.h> #include <extcdecl.h>
#include "ba1.h" #include "ba1.h"
#include "ba0100a.h" #include "ba0100a.h"
#include "ba1500a.h" #include "ba1500a.h"
#define USERADR 26952 #define USERADR 26952
#define AGAADR 26953 #define AGAADR 26953
#define PRASSIADR 26954 #define PRASSIADR 26954
#define K1 0x4500 #define K1 0x4500
#define BYTEMASK 0x00FF #define BYTEMASK 0x00FF
#define UBYTEMASK 0xFF00 #define UBYTEMASK 0xFF00
#define MAXAUT 49 #define MAXAUT 49
enum kt { _user_key, _aga_key, _prassi_key}; enum kt { _user_key, _aga_key, _prassi_key};
#define BITTEST(w,p) (((w) & (0x0001 << (p))) != 0) #define BITTEST(w,p) (((w) & (0x0001 << (p))) != 0)
#define BITSET(w,p,v) ((v) ? ((w) |= (0x0001 << (p))) : ((w) &= (~(0x0001 << (p))))) #define BITSET(w,p,v) ((v) ? ((w) |= (0x0001 << (p))) : ((w) &= (~(0x0001 << (p)))))
class TAttivazione_moduli : public TApplication class TAttivazione_moduli : public TApplication
{ {
TMask* _msk; TMask* _msk;
kt _key_type; kt _key_type;
word _serno; word _serno;
word _port; word _port;
virtual bool create() ; virtual bool create() ;
virtual bool destroy() ; virtual bool destroy() ;
bool menu(MENU_TAG); bool menu(MENU_TAG);
void generate_key(); void generate_key();
static void keyext(const TString & s, word * v); static void keyext(const TString & s, word * v);
static bool user_hnd(TMask_field & f, KEY k); static bool user_hnd(TMask_field & f, KEY k);
static bool decode_hnd(TMask_field & f, KEY k); static bool decode_hnd(TMask_field & f, KEY k);
static bool activate_hnd(TMask_field & f, KEY k); static bool activate_hnd(TMask_field & f, KEY k);
public: public:
TAttivazione_moduli() : _msk(NULL) { _key_type = _user_key;} TAttivazione_moduli() : _msk(NULL) { _key_type = _user_key;}
}; };
HIDDEN TAttivazione_moduli& app() { return (TAttivazione_moduli &) main_app(); } HIDDEN TAttivazione_moduli& app() { return (TAttivazione_moduli &) main_app(); }
void TAttivazione_moduli::generate_key() void TAttivazione_moduli::generate_key()
{ {
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
word ud[4]; word ud[4];
INT_OFF(); INT_OFF();
HL_ON(_port, USERADR); HL_ON(_port, USERADR);
ud[0] = HL_RD(_port, 48); ud[0] = HL_RD(_port, 48);
ud[1] = HL_RD(_port, 49); ud[1] = HL_RD(_port, 49);
ud[2] = HL_RD(_port, 50); ud[2] = HL_RD(_port, 50);
ud[3] = HL_RD(_port, 51); ud[3] = HL_RD(_port, 51);
HL_OFF(_port); HL_OFF(_port);
INT_ON(); INT_ON();
#else #else
int ud[4]; int ud[4];
HL_READ(48, &ud[0]); HL_READ(48, &ud[0]);
HL_READ(49, &ud[1]); HL_READ(49, &ud[1]);
HL_READ(50, &ud[2]); HL_READ(50, &ud[2]);
HL_READ(51, &ud[3]); HL_READ(51, &ud[3]);
#endif #endif
int nmod = 0; int nmod = 0;
_msk->set(F_K2, format("%04X%04X%04X%04X", ud[0], ud[1], ud[2], ud[3])); _msk->set(F_K2, format("%04X%04X%04X%04X", ud[0], ud[1], ud[2], ud[3]));
for (int i = 1; i < MAXAUT; i++) for (int i = 1; i < MAXAUT; i++)
{ {
const int pos = _msk->id2pos(F_BASE + i); const int pos = _msk->id2pos(F_BASE + i);
if (pos >= 0 && has_module(i, CHK_DONGLE)) if (pos >= 0 && has_module(i, CHK_DONGLE))
{ {
_msk->fld(pos).set("X"); _msk->fld(pos).set("X");
nmod++; nmod++;
} }
} }
_serno = SerNo; _serno = SerNo;
ud[0] = _serno; ud[0] = _serno;
ud[1] = K1 | (nmod & BYTEMASK); ud[1] = K1 | (nmod & BYTEMASK);
long & l = (long &) ud[2]; long & l = (long &) ud[2];
TDate d(TODAY); TDate d(TODAY);
l = (long) d; l = (long) d;
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
INT_OFF(); INT_OFF();
HL_ON(_port, ModAd); HL_ON(_port, ModAd);
K_EYE(_port, (unsigned char *) ud, HLBLOCK); K_EYE(_port, (unsigned char *) ud, HLBLOCK);
HL_OFF(_port); HL_OFF(_port);
INT_ON(); INT_ON();
#else #else
HL_CODE(EYECAST &ud[0], HLBLOCK); HL_CODE(EYECAST &ud[0], HLBLOCK);
#endif #endif
_msk->set(F_K1, format("%04X%04X%04X%04X", ud[0], ud[1], ud[2], ud[3])); _msk->set(F_K1, format("%04X%04X%04X%04X", ud[0], ud[1], ud[2], ud[3]));
_msk->set(F_SN, SerNo); _msk->set(F_SN, SerNo);
_msk->set(F_DT, d.string()); _msk->set(F_DT, d.string());
} }
int hexdigit(char c) int hexdigit(char c)
{ {
static char s[] = "0123456789ABCDEF"; static char s[] = "0123456789ABCDEF";
int i = strlen(s); int i = strlen(s);
while (i-- >= 0) while (i-- >= 0)
if (s[i] == c) if (s[i] == c)
break; break;
return i; return i;
} }
void TAttivazione_moduli::keyext(const TString& s, word * val) void TAttivazione_moduli::keyext(const TString& s, word * val)
{ {
for (int i = 0 ; i < 4; i++) for (int i = 0 ; i < 4; i++)
{ {
const int off = i * 4; const int off = i * 4;
word & l = val[i]; word & l = val[i];
l = 0; l = 0;
for (int j = 0; j < 4; j++) for (int j = 0; j < 4; j++)
l = l * 16 + hexdigit(s[off + j]); l = l * 16 + hexdigit(s[off + j]);
} }
} }
bool TAttivazione_moduli::user_hnd(TMask_field & f, KEY k) bool TAttivazione_moduli::user_hnd(TMask_field & f, KEY k)
{ {
const TString16 k4(f.get()); const TString16 k4(f.get());
if (!f.to_check(k) || k4.empty()) return TRUE; if (!f.to_check(k) || k4.empty()) return TRUE;
TMask & m = f.mask(); TMask & m = f.mask();
word ud1[4], ud2[4], port = app()._port; word ud1[4], ud2[4], port = app()._port;
const TString16 k3(m.get(F_K3)); const TString16 k3(m.get(F_K3));
keyext(k3, ud1); keyext(k3, ud1);
keyext(k4, ud2); keyext(k4, ud2);
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
INT_OFF(); INT_OFF();
HL_ON(port, ModAd); HL_ON(port, ModAd);
K_EYE(port, (unsigned char *) ud1, HLBLOCK); K_EYE(port, (unsigned char *) ud1, HLBLOCK);
HL_OFF(port); HL_OFF(port);
INT_ON(); INT_ON();
#else #else
HL_CODE(EYECAST ud1, HLBLOCK); HL_CODE(EYECAST ud1, HLBLOCK);
#endif #endif
const long & l = (long &) ud1[0]; const long & l = (long &) ud1[0];
TDate d(l), d1(TODAY); TDate d(l), d1(TODAY);
d.addmonth(3); d.addmonth(3);
if (d < d1) if (d < d1)
return f.error_box("data non valida"); return f.error_box("data non valida");
if ((ud1[2] & UBYTEMASK) != K1 || ud1[3] != app()._serno) if ((ud1[2] & UBYTEMASK) != K1 || ud1[3] != app()._serno)
return f.error_box("primo codice errato"); return f.error_box("primo codice errato");
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
INT_OFF(); INT_OFF();
HL_ON(port, ModAd); HL_ON(port, ModAd);
ok = K_EYE(port, (unsigned char *) ud2, HLBLOCK); K_EYE(port, (unsigned char *) ud2, HLBLOCK);
HL_OFF(port); HL_OFF(port);
INT_ON(); INT_ON();
#else #else
HL_CODE(EYECAST ud2, HLBLOCK); HL_CODE(EYECAST ud2, HLBLOCK);
#endif #endif
for (int i = 0; i < 4; i++) ud2[i] ^= app()._serno; for (int i = 0; i < 4; i++) ud2[i] ^= app()._serno;
if (ud2[3] != 0) if (ud2[3] != 0)
return f.error_box("secondo codice errato"); return f.error_box("secondo codice errato");
for (i = 1; i < MAXAUT; i++) for (i = 1; i < MAXAUT; i++)
{ {
const int af = i - 1; const int af = i - 1;
const int pos = m.id2pos(F_BASE + i); const int pos = m.id2pos(F_BASE + i);
if (pos >= 0) if (pos >= 0)
m.fld(pos).set(BITTEST(ud2[af / 16], af % 16) ? "X" : " "); m.fld(pos).set(BITTEST(ud2[af / 16], af % 16) ? "X" : " ");
} }
if (k == K_ENTER) if (k == K_ENTER)
{ {
keyext(k4, ud2); keyext(k4, ud2);
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
INT_OFF(); INT_OFF();
HL_ON(port, ModAd); HL_ON(port, ModAd);
HL_ON(port, ModAd); HL_ON(port, ModAd);
HL_WR(port, 48, ud2[0]); HL_WR(port, 48, ud2[0]);
HL_WR(port, 49, ud2[1]); HL_WR(port, 49, ud2[1]);
HL_WR(port, 50, ud2[2]); HL_WR(port, 50, ud2[2]);
HL_WR(port, 51, ud2[3]); HL_WR(port, 51, ud2[3]);
HL_OFF(port); HL_OFF(port);
INT_ON(); INT_ON();
#else #else
HL_WRITE(48, ud2[0]); HL_WRITE(48, ud2[0]);
HL_WRITE(49, ud2[1]); HL_WRITE(49, ud2[1]);
HL_WRITE(50, ud2[2]); HL_WRITE(50, ud2[2]);
HL_WRITE(51, ud2[3]); HL_WRITE(51, ud2[3]);
#endif #endif
} }
return TRUE; return TRUE;
} }
bool TAttivazione_moduli::decode_hnd(TMask_field & f, KEY k) bool TAttivazione_moduli::decode_hnd(TMask_field & f, KEY k)
{ {
const TString16 k2(f.get()); const TString16 k2(f.get());
if (!f.to_check(k) || k2.empty()) return TRUE; if (!f.to_check(k) || k2.empty()) return TRUE;
TMask & m = f.mask(); TMask & m = f.mask();
word ud1[4], ud2[4], port = app()._port; word ud1[4], ud2[4], port = app()._port;
const TString16 k1(m.get(F_K1)); const TString16 k1(m.get(F_K1));
keyext(k1, ud1); keyext(k1, ud1);
keyext(k2, ud2); keyext(k2, ud2);
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
INT_OFF(); INT_OFF();
HL_ON(port, USERADR); HL_ON(port, USERADR);
K_EYE(port, (unsigned char *) ud1, HLBLOCK); K_EYE(port, (unsigned char *) ud1, HLBLOCK);
HL_OFF(port); HL_OFF(port);
INT_ON(); INT_ON();
#else #else
HL_CODE(EYECAST ud1, HLBLOCK); HL_CODE(EYECAST ud1, HLBLOCK);
#endif #endif
long & l = (long &) ud1[2]; long & l = (long &) ud1[2];
const TDate d(l); const TDate d(l);
app()._serno = ud1[0]; app()._serno = ud1[0];
if ((ud1[1] & UBYTEMASK) != K1) if ((ud1[1] & UBYTEMASK) != K1)
return f.error_box("primo codice errato"); return f.error_box("primo codice errato");
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
INT_OFF(); INT_OFF();
HL_ON(port, USERADR); HL_ON(port, USERADR);
K_EYE(port, (unsigned char *) ud2, HLBLOCK); K_EYE(port, (unsigned char *) ud2, HLBLOCK);
HL_OFF(port); HL_OFF(port);
INT_ON(); INT_ON();
#else #else
HL_CODE(EYECAST ud2, HLBLOCK); HL_CODE(EYECAST ud2, HLBLOCK);
#endif #endif
for (int i = 0; i < 4; i++) ud2[i] ^= app()._serno; for (int i = 0; i < 4; i++) ud2[i] ^= app()._serno;
if (ud2[3] != 0) if (ud2[3] != 0)
return f.error_box("secondo codice errato"); return f.error_box("secondo codice errato");
m.set(F_SN, app()._serno); m.set(F_SN, app()._serno);
m.set(F_DT, d.string()); m.set(F_DT, d.string());
for (i = 1; i < MAXAUT; i++) for (i = 1; i < MAXAUT; i++)
{ {
const int af = i - 1; const int af = i - 1;
const int pos = m.id2pos(F_BASE + i); const int pos = m.id2pos(F_BASE + i);
if (pos >= 0) if (pos >= 0)
m.fld(pos).set(BITTEST(ud2[af / 16], af % 16) ? "X" : " "); m.fld(pos).set(BITTEST(ud2[af / 16], af % 16) ? "X" : " ");
} }
return TRUE; return TRUE;
} }
bool TAttivazione_moduli::activate_hnd(TMask_field & f, KEY k) bool TAttivazione_moduli::activate_hnd(TMask_field & f, KEY k)
{ {
if (!f.to_check(k)) return TRUE; if (!f.to_check(k)) return TRUE;
TMask & m = f.mask(); TMask & m = f.mask();
word ud1[4], ud2[4], port = app()._port; word ud1[4], ud2[4], port = app()._port;
int nmod = 0; int nmod = 0;
for (int i = 0; i < 4; i++) ud2[i] = 0; for (int i = 0; i < 4; i++) ud2[i] = 0;
for (i = 1; i < MAXAUT; i++) for (i = 1; i < MAXAUT; i++)
{ {
const int af = i - 1; const int af = i - 1;
const int pos = m.id2pos(F_BASE + i); const int pos = m.id2pos(F_BASE + i);
if (pos >= 0 && m.get_bool(F_BASE + i)) if (pos >= 0 && m.get_bool(F_BASE + i))
{ {
BITSET(ud2[af / 16], af % 16, TRUE); BITSET(ud2[af / 16], af % 16, TRUE);
nmod++; nmod++;
} }
} }
for (i = 0; i < 4; i++) ud2[i] ^= app()._serno; for (i = 0; i < 4; i++) ud2[i] ^= app()._serno;
const TDate d(m.get(F_DT)); const TDate d(m.get(F_DT));
long & l = (long &) ud1[0]; long & l = (long &) ud1[0];
l = (long) d; l = (long) d;
ud1[2] = K1 | (nmod & UBYTEMASK); ud1[2] = K1 | (nmod & UBYTEMASK);
ud1[3] = app()._serno; ud1[3] = app()._serno;
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
INT_OFF(); INT_OFF();
HL_ON(port, ModAd); HL_ON(port, ModAd);
K_EYE(port, (unsigned char *) ud1, HLBLOCK); K_EYE(port, (unsigned char *) ud1, HLBLOCK);
K_EYE(port, (unsigned char *) ud2, HLBLOCK); K_EYE(port, (unsigned char *) ud2, HLBLOCK);
HL_OFF(port); HL_OFF(port);
INT_ON(); INT_ON();
#else #else
HL_CODE(EYECAST ud1, HLBLOCK); HL_CODE(EYECAST ud1, HLBLOCK);
HL_CODE(EYECAST ud2, HLBLOCK); HL_CODE(EYECAST ud2, HLBLOCK);
#endif #endif
m.set(F_K4, format("%04X%04X%04X%04X", ud2[0], ud2[1], ud2[2], ud2[3])); m.set(F_K4, format("%04X%04X%04X%04X", ud2[0], ud2[1], ud2[2], ud2[3]));
m.set(F_K3, format("%04X%04X%04X%04X", ud1[0], ud1[1], ud1[2], ud1[3])); m.set(F_K3, format("%04X%04X%04X%04X", ud1[0], ud1[1], ud1[2], ud1[3]));
return TRUE; return TRUE;
} }
bool TAttivazione_moduli::create() bool TAttivazione_moduli::create()
{ {
if (user() != "PRASSI") if (user() != "PRASSI")
return error_box("Utente non abilitato all'uso di questo programma"); return error_box("Utente non abilitato all'uso di questo programma");
_msk = new TMask("ba1500a") ; _msk = new TMask("ba1500a") ;
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
if (Hl_Port(AGAADR) != 0) if (Hl_Port(AGAADR) != 0)
_key_type = _aga_key; _key_type = _aga_key;
else else
if (Hl_Port(PRASSIADR) != 0) if (Hl_Port(PRASSIADR) != 0)
_key_type = _prassi_key; _key_type = _prassi_key;
_port = Hl_Port(USERADR); _port = Hl_Port(USERADR);
#else #else
HL_LOGOUT(); HL_LOGOUT();
if (HL_LOGIN(AGAADR, DONT_CARE, REFKEY, VERKEY) == STATUS_OK) if (HL_LOGIN(AGAADR, DONT_CARE, REFKEY, VERKEY) == STATUS_OK)
_key_type = _aga_key; _key_type = _aga_key;
else else
{ {
HL_LOGOUT(); HL_LOGOUT();
if (HL_LOGIN(PRASSIADR, DONT_CARE, REFKEY, VERKEY) == STATUS_OK) if (HL_LOGIN(PRASSIADR, DONT_CARE, REFKEY, VERKEY) == STATUS_OK)
_key_type = _prassi_key; _key_type = _prassi_key;
} }
HL_LOGOUT(); HL_LOGOUT();
HL_LOGIN(USERADR, DONT_CARE, REFKEY, VERKEY); HL_LOGIN(USERADR, DONT_CARE, REFKEY, VERKEY);
#endif #endif
switch (_key_type) switch (_key_type)
{ {
case _user_key: case _user_key:
{ {
_msk->disable(F_K1); _msk->disable(F_K1);
_msk->disable(F_K2); _msk->disable(F_K2);
_msk->set_handler(F_K4, user_hnd); _msk->set_handler(F_K4, user_hnd);
generate_key(); generate_key();
for (int i = 1; i < ENDAUT; i++) for (int i = 1; i < ENDAUT; i++)
{ {
const int pos = _msk->id2pos(F_BASE + i); const int pos = _msk->id2pos(F_BASE + i);
if (pos >= 0) _msk->fld(pos).disable(); if (pos >= 0) _msk->fld(pos).disable();
} }
} }
break; break;
case _aga_key: case _aga_key:
case _prassi_key: case _prassi_key:
{ {
_msk->set_handler(F_K2, decode_hnd); _msk->set_handler(F_K2, decode_hnd);
_msk->disable(F_K3); _msk->disable(F_K3);
_msk->disable(F_K4); _msk->disable(F_K4);
for (int i = 1; i < MAXAUT; i++) for (int i = 1; i < MAXAUT; i++)
{ {
const int pos = _msk->id2pos(F_BASE + i); const int pos = _msk->id2pos(F_BASE + i);
if (pos >= 0) if (pos >= 0)
_msk->set_handler(F_BASE + i, activate_hnd); _msk->set_handler(F_BASE + i, activate_hnd);
} }
} }
break; break;
default: default:
break; break;
} }
dispatch_e_menu(BAR_ITEM(1)); dispatch_e_menu(BAR_ITEM(1));
return TRUE; return TRUE;
} }
bool TAttivazione_moduli::destroy() bool TAttivazione_moduli::destroy()
{ {
if (_msk != NULL) delete _msk; if (_msk != NULL) delete _msk;
return TRUE; return TRUE;
} }
bool TAttivazione_moduli::menu(MENU_TAG) bool TAttivazione_moduli::menu(MENU_TAG)
{ {
_msk->run(); _msk->run();
return FALSE; return FALSE;
} }
int ba1500(int argc, char** argv) int ba1500(int argc, char** argv)
{ {
TAttivazione_moduli a ; TAttivazione_moduli a ;
a.run(argc, argv, "Attivazione moduli"); a.run(argc, argv, "Attivazione moduli");
return 0; return 0;
} }