/* --------------------------------------------------------------------	*/
/*									*/
/*				EUTRON					*/
/*									*/
/*	   	Via Gandhi 12 - 24048 Treviolo BG -  Italy		*/
/*									*/
/*	Tel. +39-35-201003 - Fax +39-35-201277 - BBS +39-35-201144	*/
/*									*/
/* --------------------------------------------------------------------	*/
/*									*/
/*	Language    : C							*/
/*	Application : SkeyTsr						*/
/*	Module      : skeytsr.h						*/
/*	Version     : 1.0						*/
/*	Date	    : 18.4.1995						*/
/*	Note	    : 							*/
/*									*/
/* --------------------------------------------------------------------	*/

#ifndef	INC_SKEYTSR_H
#define	INC_SKEYTSR_H

/* --------------------------------------------------------------------	*/
/* Smartkey mode codes							*/
/* --------------------------------------------------------------------	*/

#define	SCRAMBLING_MODE		's'
#define	READING_MODE		'r'
#define	WRITING_MODE		'w'
#define	FIXING_MODE		'f'
#define	LOCATING_MODE		'l'
#define	COMPARING_MODE		'c'
#define	PROGRAMMING_MODE	'p'
#define	MODEL_READING_MODE	'm'
#define	ENCRYPTING_MODE		'e'
#define	BLOCK_READING_MODE	"br"
#define	BLOCK_WRITING_MODE	"bw"

/* --------------------------------------------------------------------	*/
/* Smartkey models							*/
/* --------------------------------------------------------------------	*/

#define	SKEY_NONE	'0'		/* No Smartkey			*/
#define SKEY_FX		'1'		/* Smartkey mod. FX		*/
#define SKEY_PR		'2'		/* Smartkey mod. PR		*/
#define SKEY_EP		'3'		/* Smartkey mod. EP		*/
#define	SKEY_NET_5	'4'		/* Smartkey mod. NET 5 users	*/
#define	SKEY_NET_10	'5'		/* Smartkey mod. NET 10 users	*/
#define	SKEY_NET_25	'6'		/* Smartkey mod. NET 25 users	*/
#define	SKEY_NET_50	'7'		/* Smartkey mod. NET 50 users	*/
#define	SKEY_NET_NL	'8'		/* Smartkey mod. NET no limit	*/
#define	SKEY_SP		'9'		/* Smartkey mod. SP		*/
#define	SKEY_NET	'A'		/* Smartkey mod. NET		*/

/* --------------------------------------------------------------------	*/
/* Return codes								*/
/* --------------------------------------------------------------------	*/

#define ST_OK			0	/* No errors			*/
#define ST_NONE_KEY		-1	/* No Smartkey present		*/
#define ST_SYNT_ERR		-2	/* Syntax error			*/
#define ST_LABEL_FAILED 	-3	/* Uncorrect label		*/
#define ST_PW_DATA_FAILED	-4	/* Uncorrect password or data	*/
#define ST_NET_ERROR		-5	/* Lan error			*/
#define	ST_CLOSE_ERROR		-6	/* Attempting to CLOSE  without	*/
					/* OPENing			*/
#define ST_ACCESS_ERROR		-7	/* Attempting to ACCESS without	*/
					/* OPENing			*/
#define ST_USER_ERROR		-8	/* Max user reached 		*/
#define	ST_NET_PWD_ERR		-9	/* Net password wrong		*/
#define	ST_TSR_NOT_INST		-10	/* SKEYSRV not found		*/
#define	ST_INIT_ERROR		-11	/* Insufficient PC memory	*/
#define ST_PATH_ERR		-12	/* Path error or file not found */
#define	ST_DRIVER_NOT_INST	-13	/* SKEYTSR not installed	*/
#define	ST_TOO_MANY_OPEN_KEY	-14	/* Too many open SmartKey	*/
#define	ST_NET_PASS_INVALID	-15	/* Invalid net password		*/
#define	ST_HW_FAILURE		-20	/* Smartkey damaged		*/

/* --------------------------------------------------------------------	*/
/* Field length								*/
/* --------------------------------------------------------------------	*/

#define LABEL_LENGTH		16
#define PASSWORD_LENGTH		16
#define DATA_LENGTH		64
#define EXTENDED_DATA_LENGTH	352
#define	SCRAMBLE_LENGTH		8

/* --------------------------------------------------------------------	*/
/* --------------------------------------------------------------------	*/

#define NET_KEY_OPEN		'O'
#define NET_KEY_ACCESS		'A'
#define NET_KEY_CLOSE		'C'
#define USER_NUMBER_MODE	'U'

/* --------------------------------------------------------------------	*/
/* Communication structure definition					*/
/* --------------------------------------------------------------------	*/

#pragma pack(1)

typedef struct smartkey {
	short		net_command;
	unsigned long	net_password;
	short		lpt;
	short		command;
	unsigned char	label[LABEL_LENGTH];
	unsigned char	password[PASSWORD_LENGTH];
	unsigned char	data[DATA_LENGTH];
	short		fail_counter;
	short		status;
	unsigned char	ext_data[EXTENDED_DATA_LENGTH];
} KEY_NET;

#pragma pack()

/* --------------------------------------------------------------------	*/
/* Interface function prototype						*/
/* --------------------------------------------------------------------	*/


short __far __pascal smartlink(KEY_NET __far *pSkey);

#endif