alex 0c0abd6589 This commit was generated by cvs2svn to compensate for changes in r5942,
which included commits to RCS files with non-trunk default branches.

git-svn-id: svn://10.65.10.50/trunk@5943 c028cbd2-c16b-5b4b-a496-9718f37d4682
1998-01-15 16:39:02 +00:00

65 lines
1.2 KiB
C
Executable File

#include "hlapi_c.h"
#define BOOLEAN int
#define FALSE 0
#define TRUE 1
#define HLBLOCK 1
#define CBITTEST(w,p) (((w) & (0x0001 << (p))) != 0)
Word _int_tab0[4] = {0xFFFF, 0xFFFF, 0xFFFF, 0x0000};
Word SerNo = -1;
/*
Restituisce il numero di serie della chiave
*/
Word getser()
{
Word Val[4];
BOOLEAN ok;
int i;
SerNo = -1;
if (HL_AVAIL() == STATUS_OK)
{
SerNo = 0;
HL_READ(0, &Val[0]);
HL_READ(1, &Val[1]);
HL_READ(2, &Val[2]);
HL_READ(3, &Val[3]);
HL_CODE(EYECAST &Val[0], HLBLOCK);
if (Val[0] == 0xFAE8)
{
SerNo = Val[1];
return(Val[1]);
}
}
return (0);
}
/*
Restituisce l'autorizzazione ad utilizzare un modulo
*/
BOOLEAN CGetAut(af)
int af; /* numero del modulo */
{
int i;
BOOLEAN ok;
if (!af) return(!af);
if (af > 48) return(FALSE);
if (!SerNo) return(!getser());
HL_READ(48, &_int_tab0[0]);
HL_READ(49, &_int_tab0[1]);
HL_READ(50, &_int_tab0[2]);
HL_READ(51, &_int_tab0[3]);
HL_CODE(EYECAST &_int_tab0[0], HLBLOCK);
for (i = 0; i < 4; i++) _int_tab0[i] ^= SerNo;
if (_int_tab0[3]) return(FALSE);
af--;
return(CBITTEST(_int_tab0[af / 16], af % 16));
}