Rif. mod. 95/19. Svincolati definitivamente i sorgenti dal direttorio

/disk1/p.uno.


git-svn-id: svn://10.65.10.50/trunk@1811 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
angelo 1995-09-11 15:31:07 +00:00
parent af5dfb21f9
commit d24f85fc6c
18 changed files with 3238 additions and 2031 deletions

281
include/ccommon.h Executable file

@ -0,0 +1,281 @@
#ifndef __CCOMMON_H
#define __CCOMMON_H
#define M_TERMINFO
#ifdef __WATCOMC__
#pragma aux MS_C "_*" parm caller [] value struct float struct routine [ax] modify [ax bx cx dx es];
#endif
#ifdef XVT
#include <xvt.h>
#undef BOOLEAN
#include <checks.h>
#endif
#ifdef __GNUC__
#define __PACKED__ __attribute__ ((packed))
#define __ALIGNED__ __attribute__ ((aligned(2)))
#define __PACK_1__
#else
#define __PACKED__
#define __ALIGNED__
#endif
#ifdef DOS
#include <stdio.h>
#include <stdlib.h>
#define _NO_STDIO
#include <ctype.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <fcntl.h>
#include <signal.h>
#include <setjmp.h>
#else
#ifdef __cplusplus
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#define _NO_STDIO
#include <sys/types.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <time.h>
#include <fcntl.h>
#include <signal.h>
#include <setjmp.h>
#else
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <ctype.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <fcntl.h>
#include <signal.h>
#include <setjmp.h>
#endif
#endif
#include <gm.h>
#if !defined(__MSHELL_H) && !defined(FOXPRO)
#include "mshell.h"
#endif
#define CHR(c) (c)
#define ORD(c) (c)
#define ODD(c) (((c) % 2) != 0)
#ifdef DOS
/* @(!) 2.3.01.316 modif. #define TMPFNAME(p,n) sprintf(p, "\\tmp\\%s.tmp", (n)); */
#define TMPFNAME(p,n) tmpfname((p),(n))
/* @(:) 2.3.01.316 */
#define DIRSEP '\\'
#else
#define TMPFNAME(p,n) sprintf(p, "/usr/tmp/%s%-d", (n), getpid());
#define DIRSEP '/'
#endif
#define HIDDEN static
#define UPCASE(c) toupper(c)
#define LOWCASE(c) tolower(c)
#define LENGTH(s) strlen(s)
#define STREMPTY(s) (!(LENGTH(s)))
#define STRNOTEMPTY(s) (!STREMPTY(s))
#define STRCMP(s1,op,s2) (strcmp(s1,s2) op 0)
#define CSTR(n,s) sprintf((s), "%-d", (n))
#define CSTR4(n,s) sprintf((s), "%-ld", (n))
#define MAXDATA cpackdata("31-12-50")
#define MINDATA cpackdata("01-01-51")
#define EMPTYDATA cpackdata(" - - ")
#define MONTHNAME(i) months[(i) - 1]
#define CCONVINT(s) atoi(s)
#define CONVLONG(s) atol(s)
#define BADR(x) ((x) - 1)
#define WINHND(hw) warr[(hw)].w
/* @(!) 2.3.01.69 */
#define WINHNDB(hw) warr[(hw)].wb
/* @(:) 2.3.01.69 */
#define WINFLD(hw,f) warr[(hw)].f
#define POSTWIN(hw) WINFLD(hw,posted) = TRUE
#define UNPOSTWIN(hw) WINFLD(hw,posted) = FALSE
#define CCLEAREOL(w) xwclrtoeol(WINHND(w))
#define CCLEAREOS(w) xwclrtobot(WINHND(w))
#define CCLEARWIN(w) xpaint(WINHND(w), setattr[warr[(w)].bkat][iscolordisp])
#define INSET(c,s) (ustrchr((s), (c)) != (uchar *) NULL)
#define CBITTEST(w,p) (((w) & (0x0001 << (p))) != 0)
#define CBITSET(w,p,v) ((v) ? ((w) |= (0x0001 << (p))) : ((w) &= (~(0x0001 << (p)))))
/* @(!) 2.3.01.temp */
#ifdef M_I386
#define BOOLEAN short
#else
/* @(:) 2.3.01.temp */
#define BOOLEAN int
/* @(!) 2.3.01.temp */
#endif
/* @(:) 2.3.01.temp */
#define NoErr 0
#define BADSIG (int (*)()) -1
#define MAXMENUITEM 21
#define MAXWIN 20
#define MAXBORDERS 8
#define MAXATTRS 20
#define BackCh '_'
#define directory "dir.gen"
#define ntrrec "trc.gen"
#define nditta "dta.gen"
#define printers "prt.gen"
#define prcodes "prc.gen"
#define WWMESS 0
#define WWBAR 1
/* gia' definito in gm.h
typedef unsigned int word;
*/
typedef unsigned char byte;
#ifndef DOS
typedef unsigned char uchar;
#endif
#ifdef XVT_OS
#ifdef DOS
typedef unsigned char uchar;
#endif
typedef long HWND;
#else
#endif
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__ ;
/* @(!) 2.3.01.temp */
#ifdef M_I386
short numero __PACKED__ ;
short tab0[20] __PACKED__ ;
#else
/* @(:) 2.3.01.temp */
int numero;
int tab0[20];
/* @(!) 2.3.01.temp */
#endif
/* @(:) 2.3.01.temp */
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 char Str8[9];
typedef char Str25[26];
typedef char Str30[32];
typedef char Str80[82];
typedef char Str255[256];
typedef uchar StCh[256];
typedef long TrDate;
typedef struct {
char name[26];
char explic[82];
} MenuItem;
typedef MenuItem MenuArray[MAXMENUITEM + 1];
typedef char PathSt[42];
extern Str80 cprefix;
extern TDitta cditta;
extern TrDate dt;
extern Str8 sdt;
extern char months[12][12];
extern BOOLEAN iscolordisp;
#ifdef __cplusplus
extern "C" {
#endif
uchar *ustrchr(uchar *, uchar);
uchar *setof(uchar *, ELLIPSES);
uchar *delset(uchar *, ELLIPSES);
int positn(char *, char *, int);
void cdate(char *);
void ctimeloc(char *);
uchar CReadKeyb(void);
char *ToASCIIZ(char *);
char *ToASCII(char *);
void CDispStatus(char *);
BOOLEAN cverdata(char *);
TrDate cpackdata(char *);
void ceditdata(TrDate ,char *);
void cgetdata(TrDate *,char *);
void cputdata(char *);
int month(TrDate);
int year(TrDate);
int day(TrDate);
TrDate makedata(int,int,int);
TrDate addmonth(TrDate,int);
TrDate addyear(TrDate,int);
void cgettime(char *);
char *CCopy(char *,int ,int );
int CBitPos(int );
BOOLEAN CGetAut(int );
char *CGetConf(int );
void CMaskP(char *,char *,int , int);
char *CUpString(char *);
char *CLowString(char *);
/* @(!) 2.3.00.21 */
char *strfset(char *, char *);
/* @(:) 2.3.00.21 */
char CSetDrive(char );
char CGetDrive(void );
int CMkDir(char *);
int CRmDir(char *);
int CChgDir(char *);
int CRenameFil(char *,char *);
int CRenameDir(char *,char *);
int CGetDir(char *);
long CDiskSpace(char );
void CSetString(char *,char *,BOOLEAN, BOOLEAN, int ,int ,char );
BOOLEAN ckeypress(void );
void genhelp(void );
uchar CReadKeyb(void );
char *esc(char *);
void CInitProg(void );
void CEndProg(void );
int execprog(int ,char *, ELLIPSES);
void CEditDec(DEC *,int ,int ,char *);
void CConvDec(char *,DEC *);
int CIOResult(void );
TDitta *CGetDitta(char *);
void CPutDitta(char *,TDitta *);
void CClearKb(void );
void crtrim(char *);
void cltrim(char *);
void CSplitString(char *,int ,char *,char *);
void CSpace(char *, int);
uchar editpref(BOOLEAN, BOOLEAN, BOOLEAN);
char **getlinefd(char *, char, char);
word getkeyid(void);
void addtokeybar(char *, word);
void delfromkeybar(word);
uchar *setofkeybar(word);
/* @(!) 2.3.01.134 */
uchar *strsetofkeybar(char *);
/* @(:) 2.3.01.134 */
/* @(!) 2.3.01.223 */
void suspendkey(char *);
void resumekey(char *);
/* @(:) 2.3.01.223 */
/* @(!) 2.3.01.316 */
#ifdef DOS
void tmpfname(char *,char *);
#endif
/* @(:) 2.3.01.316 */
#ifdef __cplusplus
};
#endif
#endif /* __CCOMMON_H */

@ -1,29 +1,9 @@
/*
@(SH) Funzioni per la gestione dei file a record.
@(M$) PRIVATE
CalcPos(Rec,Len,Base) : Calcola la posizione del record nel file
@(C$) PRIVATE
LOCKSEM : 'locksem' ; nome del semaforo utilizzato per il lock
@(VG$) PRIVATE
ld : struttura su disco che contien i dati per i lock sui file
sizeld : numero di byte occupati dalla struttura ld
semres : flag per l'ok delle operazioni sui semafori
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
#include "ccustio.h"
#include "ccustio.h"
#include "checks.h"
#ifdef DOS
#include <sys/types.h>
#include <sys/types.h>
#endif
#include <sys/stat.h>
#include <sys/stat.h>
#ifndef DOS
#include <sys/ipc.h>
#include <sys/sem.h>

81
include/ccustio.h Executable file

@ -0,0 +1,81 @@
#ifndef __CCUSTIO_H
#define __CCUSTIO_H
#ifndef DOS
#include <unistd.h>
#endif
#include <errno.h>
#ifndef __CCOMMON_H
#include "ccommon.h"
#endif
#ifndef __GENCONST_H
#include "genconst.h"
#endif
#define BlockLenIO 512
#define Valid 0
#define Deleted 1
typedef char *FileName;
typedef char *RecType;
typedef long RecNoType;
typedef struct {
int F;
FILE *Fd;
int IOR;
int LenRec;
int BaseFil;
unsigned LockMode;
RecNoType lpos;
PathSt name;
/* @(!) 2.3.01.325 */
RecNoType lkpos;
/* @(:) 2.3.01.325 */
} SecDef ;
#ifdef DOS
#define TESTLOCK(x) (/*test_share() && */ ((x) == EACCES || (x) == EAGAIN))
#define DEADLOCK(x) (/*test_share() && */ (x) == EDEADLOCK)
#else
#define TESTLOCK(x) (((x) == EACCES) || ((x) == EAGAIN) || ((x) == ENOLCK))
#define DEADLOCK(x) (((x) == EDEADLOCK) || ((x) == EDEADLK))
#endif
#define BLOCKEXT(len,rec) (((((RecNoType) (len)) * ((RecNoType) (rec))) / BlockLenIO) + 1)
/* @(!) 2.3.01.325 */
#ifdef DOS
#define ASPETTA(x) (sleep_dos(x))
#else
#define ASPETTA(x) (sleep(x))
#endif
/* @(:) 2.3.01.325 */
#ifdef __cplusplus
extern "C" {
#endif
void CLockRec(SecDef *, RecNoType, unsigned);
void CVerify(SecDef *,char *);
void COpen(SecDef *,char *, unsigned, unsigned, unsigned);
void CCreate(SecDef *,char *,unsigned ,unsigned ,RecNoType);
void CChsize(SecDef *,char *,unsigned ,unsigned ,RecNoType);
void CClose(SecDef *);
void CDelete(SecDef *,char *);
void CRead(SecDef *,RecType,RecNoType ,unsigned );
void CWrite(SecDef *,RecType,RecNoType ,unsigned );
void IDeleteRec(RecType);
void IRecallRec(RecType);
BOOLEAN IRecIsDeleted(RecType);
BOOLEAN ITestLock(int );
/* @(!) 2.3.01.325 modificata int excllock(char *,BOOLEAN);*/
/* @(!) 2.3.01.325 modificata int exclunlock(char *,BOOLEAN);*/
int excllock(char *,BOOLEAN);
int exclunlock(char *,BOOLEAN);
int sleep_dos(int);
/* @(:) 2.3.01.325 */
BOOLEAN test_share(void);
#ifdef __cplusplus
};
#endif
#endif /* __CCUSTIO_H */

File diff suppressed because it is too large Load Diff

152
include/cfiles.h Executable file

@ -0,0 +1,152 @@
#ifndef __CFILES_H
#define __CFILES_H
#ifndef __CCUSTIO_H
#include "ccustio.h"
#endif
#define MaxFilesDir 70
#define MKFields 10
#define MaxFields 100
#define MaxKeys 8
#define glockname "xx"
#define INVFLD 255
/* @(!) 2.3.01.144 */
#define NORDIR 0
#define COMDIR 1
/* @(:) 2.3.01.144 */
typedef char FieldName[12] ;
typedef struct
{
char SysName[42] __PACKED__ ;
RecNoType EOD __PACKED__ ;
RecNoType EOX __PACKED__ ;
/* @(!) 2.3.01.temp */
#ifdef M_I386
unsigned short LenR __PACKED__ ;
#else
/* @(:) 2.3.01.temp */
unsigned int LenR ;
/* @(!) 2.3.01.temp */
#endif
/* @(:) 2.3.01.temp */
RecNoType Flags __PACKED__ ;
char Des[42] __PACKED__ ;
char FCalc[32] __PACKED__ ;
char GenPrompt[32] __PACKED__ ;
} FileDes;
typedef struct
{
FieldName Name __PACKED__ ;
byte TypeF __PACKED__ ;
byte Len __PACKED__ ;
byte Dec __PACKED__ ;
#ifdef __PACK_1__
byte junk __PACKED__ ;
#endif
/* @(!) 2.3.01.temp */
#ifdef M_I386
unsigned short RecOff __PACKED__ ;
#else
/* @(:) 2.3.01.temp */
unsigned int RecOff ;
/* @(!) 2.3.01.temp */
#endif
/* @(:) 2.3.01.temp */
} RecFieldDes ;
#if XVT_OS == XVT_OS_DOS || XVT_OS == XVT_OS_WIN
#pragma pack(2)
#endif
typedef struct
{
BOOLEAN DupKeys __ALIGNED__ ;
byte NkFields __ALIGNED__ ;
byte FieldSeq[MKFields] __PACKED__ ;
byte FromCh[MKFields] __PACKED__ ;
byte ToCh[MKFields] __PACKED__ ;
} KeyDes ;
typedef struct
{
/* @(!) 2.3.01.temp */
#ifdef M_I386
short NFields __PACKED__ ;
#else
/* @(:) 2.3.01.temp */
int NFields ;
/* @(!) 2.3.01.temp */
#endif
/* @(:) 2.3.01.temp */
RecFieldDes Fd[MaxFields] __PACKED__ ;
byte SortFd[MaxFields] __PACKED__ ;
/* @(!) 2.3.01.temp */
#ifdef M_I386
short NKeys __PACKED__ ;
#else
/* @(:) 2.3.01.temp */
int NKeys ;
/* @(!) 2.3.01.temp */
#endif
/* @(:) 2.3.01.temp */
KeyDes Ky[MaxKeys] __PACKED__ ;
} RecDes;
#ifdef __CFILES_C
SecDef rdir[2], fdir[2];
#else
extern SecDef rdir[2], fdir[2];
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* @(!) 2.3.01.144 */
void COpenDir(int, int);
void CCloseDir(int);
void COpenFile(int, FileDes *, int, int);
void CCloseFile(int, FileDes *, int);
void CGetFile(int, FileDes *, int, int);
void CPutFile(int, FileDes *, int);
/* @(:) 2.3.01.144 */
void zerofdes(FileDes *);
/* @(!) 2.3.01.144 */
void COpenRecDir(int, int);
void CCloseRecDir(int);
void CGetRec(int, RecDes *, int);
void CPutRec(int, RecDes *, int);
/* @(:) 2.3.01.144 */
void zerordes(RecDes *);
word setrdes(RecDes *);
int findfld(RecDes *,char *);
unsigned int CFieldSize(char *, RecDes *);
unsigned int CFieldDec(char *, RecDes *);
int CFieldType(char *, RecDes *);
int CGetField(char *, RecDes *, RecType, void *);
int CPutField(char *, RecDes *, void *, RecType);
int CGetFieldBuff(char *, RecDes *, RecType, char *);
int CPutFieldBuff(char *, RecDes *, char *, RecType);
int CZeroField(char *, RecDes *, RecType);
void CZeroRec(RecDes *, RecType);
int CBuildKey(RecDes *,int ,RecType, char *);
int CCalcLenKey(RecDes *,int);
char *CGetPref(void);
void CPutPref(char *);
char *CAddPref(char *);
/* @(!) 2.3.01.144 */
char *CInsPref(char *, int);
/* @(:) 2.3.01.144 */
char *CGetIdxName(char *);
/* @(!) 2.3.01.155 */
char **getlinesdf(char *, int *);
void loadrfd(RecDes *, RecType, char **, char **);
void dumprfd(RecDes *, RecType, char **, int *, int *, int *, char *);
/* @(:) 2.3.01.155 */
#ifdef __cplusplus
};
#endif
#endif /* __CFILES_H */

File diff suppressed because it is too large Load Diff

@ -1,39 +1,8 @@
/*
@(SH) Header
@(C#) PUBBLICHE
NOFLDS : massimo numero di chiavi da ordinare
@(C$) PRIVATE
MOSTMEM : numero massimo di bytes di memoria per il buffer di sort
LEASTMEM : numero minimo di bytes di memoria per il buffer di sort
@(VG#) PUBBLICHE
s_prm : struttura di un sort
s_prm.rc_len : lunghezza del record
s_prm.s_fld : vettore della struttura dei campi di sort
s_prm.s_fld[].f_pos : prima posizione del campo (contando da 1)
s_prm.s_fld[].f_len : lunghezza del campo e tipo del campo; se f_len > 0 e' una stringa; se f_len = -1 e' un intero; se f_len = -2 e' un boolean
s_prm.s_fld[].ad : a = crescente; d = decrescente
@(VG$) PRIVATE
bp : struttura di una sequenza in un buffer di merge
bp.rc : puntatore al record nel merge buffer
bp.rbuf : record rimasti nel buffer in questa sequenza di sort
bp.rdsk : record rimasti nel disco in questa sequenza di sort
-------------------------------------------------------------------------------
*/
#ifndef __CSORT_H
#define __CSORT_H
#ifndef __CCOMMON_H
#include "ccommon.h"
#endif
#ifndef __CCUSTIO_H
#include "ccustio.h"
#endif
#ifndef __CISAM_H
#include "cisam.h"
#ifndef __CFILES_H
#include "cfiles.h"
#endif
#define NOFLDS 10
@ -70,8 +39,6 @@ extern "C" {
/*----------------------- FUNZIONI VISIBILI SECONDA PARTE -------------------*/
void initsortfield (void);
int addsortfield (isfdptr, FieldName, int, int, char);
int finesortfield (isfdptr);
/* azzera l'elenco dei campi in base a cui eseguire il sort */
/* ritorna 0 se tutto ok, -1 se chiamata piu' di NOFLDS volte dopo l'ultimo initsortfield */

13
include/fldtypes.h Executable file

@ -0,0 +1,13 @@
#define NullF 0
#define AlfaF 1
#define IntF 2
#define Int4F 3
#define RealF 4
#define DateF 5
#define WordF 6
#define CharF 7
/* @(!) 2.3.01.196 */
#define BoolF 8
#define ZeroF 9
#define EZeroF 10
/* @(:) 2.3.01.196 */

117
include/genconst.h Executable file

@ -0,0 +1,117 @@
#ifndef __GENCONST_H
#define __GENCONST_H
#define NoAut 0
#define ScrVal 0
#define ScrSal 1
#define ScrNoClear 2
#define ScrNum 3
#define ScrUpp 4
#define ScrDate 5
/* @(!) 2.3.01.163 */
#define ScrNumNoTrim 6
/* @(:) 2.3.01.163 */
#define ScrAutoHlp 7
#define ScrAutoCnt 8
#define ScrAutoReq 9
#define BrGoEnd 1
#define BrInsLine 2
#define FdSt 0
#define FdEnd -1
#define NulC CHR(0)
#define C01 CHR(1)
#define C02 CHR(2)
#define Bell CHR(7)
#define BkSp CHR(8)
#define Tab CHR(9)
#define CtrlRet CHR(10)
#define Home CHR(11)
#define EndK CHR(12)
#define Ret CHR(13)
#define PgUp CHR(14)
#define PgDn CHR(15)
#define CtrlHome CHR(16)
#define CtrlEndK CHR(17)
#define CtrlPgUp CHR(18)
#define CtrlPgDn CHR(19)
#define Ins CHR(20)
#define Del CHR(127)
#define ShiftTab CHR(22)
#define Esc CHR(27)
#define Right CHR(28)
#define Left CHR(29)
#define Up CHR(30)
#define Down CHR(31)
#define Blank CHR(32)
#define LBr CHR(91)
#define F1 CHR(177)
#define F2 CHR(178)
#define F3 CHR(179)
#define F4 CHR(180)
#define F5 CHR(181)
#define F6 CHR(182)
#define F7 CHR(183)
#define F8 CHR(184)
#define F9 CHR(185)
#define F10 CHR(186)
#define SF1 CHR(187)
#define SF2 CHR(188)
#define SF3 CHR(189)
#define SF4 CHR(190)
#define SF5 CHR(191)
#define SF6 CHR(192)
#define SF7 CHR(193)
#define SF8 CHR(194)
#define SF9 CHR(195)
#define SF10 CHR(196)
#define CF1 CHR(197)
#define CF2 CHR(198)
#define CF3 CHR(199)
#define CF4 CHR(200)
#define CF5 CHR(201)
#define CF6 CHR(202)
#define CF7 CHR(203)
#define CF8 CHR(204)
#define CF9 CHR(205)
#define CF10 CHR(206)
#undef ON
#define ON TRUE
#undef OFF
#define OFF FALSE
#define NoErr 0
#define ExclLock 256 /*16#0100*/
#define AutoLock 512 /*16#0200*/
#define ManuLock 1024 /*16#0400*/
#define UnLock 4096 /*16#1000*/
#define NoLock 8192 /*16#2000*/
#define Lock 16384 /*16#4000*/
#define ShareLock 32768 /*16#8000*/
#define RecLockTypes 61440 /*16#F000*/
#define IsFirst 0 /*16#0*/
#define IsLast 1 /*16#1*/
#define IsNext 2 /*16#2*/
#define IsPrev 4 /*16#4*/
#define IsCurr 8 /*16#8*/
#define IsEqual 16 /*16#10*/
#define IsGreat 32 /*16#20*/
#define IsGtEq 64 /*16#40*/
#define IsNextN 256 /*16#100*/
#define IsPrevN 512 /*16#200*/
#define DefPrinter 1
#ifndef M_TERMINFO
#define Refresh(w) RefScrn
#define WINDOW HWND
#define Window HWND
#define window HWND
#endif
#endif /* __GENCONST_H */

72
include/getaut.c Executable file

@ -0,0 +1,72 @@
#include "ccommon.h"
#include "libdefs.h"
Word _int_tab0[4] = {0xFFFF, 0xFFFF, 0xFFFF, 0x0000};
/*
@(#) CGetAut
@(ID)
Restituisce l'autorizzazione ad utilizzare un modulo. Vedi il file modaut.h.
@(FD)
*/
BOOLEAN CGetAut(af)
int af; /* numero del modulo */
{
int i;
#ifndef DOS
BOOLEAN ok;
#endif
if (!af) return(!af);
if (af > 48) return(FALSE);
/* @(!) 2.3.01.176 */
if (demoflag)
{
/* @(!) 2.3.01.276 */
if (formflag)
_int_tab0[0] = 0x019D;
else
_int_tab0[0] = 0x010D;
/* @(:) 2.3.01.276 */
_int_tab0[1] = 0x0000;
_int_tab0[2] = 0x0000;
_int_tab0[3] = 0x0000;
af--;
return(CBITTEST(_int_tab0[af / 16], af % 16));
}
/* @(:) 2.3.01.176 */
if (!SerNo) return(!getser());
/* @(!) 2.3.01.178 */
#ifdef DOS
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);
#else
/* @(:) 2.3.01.178 */
INT_OFF();
HL_ON(Port, ModAd);
_int_tab0[0] = HL_RD(Port, 48);
_int_tab0[1] = HL_RD(Port, 49);
_int_tab0[2] = HL_RD(Port, 50);
_int_tab0[3] = HL_RD(Port, 51);
HL_OFF(Port);
INT_ON();
INT_OFF();
HL_ON(Port, ModAd);
ok = K_EYE(Port, EYECAST &_int_tab0[0], HLBLOCK);
HL_OFF(Port);
INT_ON();
/* @(!) 2.3.01.178 */
#endif
/* @(:) 2.3.01.178 */
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));
}

172
include/hlapi_c.h Executable file

@ -0,0 +1,172 @@
#ifndef __HLAPI_H
#define __HLAPI_H
/****************************************************************************/
/** **/
/** Hardlock E-Y-E **/
/** API-Structures and definitions **/
/** **/
/** This file contains some helpful defines to access a Hardlock using **/
/** the application programing interface (API) for Hardlock E-Y-E. **/
/** **/
/** (c) 1992 by ///FAST Electronic **/
/** **/
/** **/
/** Authors : Thomas Schr”ter **/
/** Henri Volk **/
/** Version : 3.0 **/
/** Date : 01-Sep-1992 **/
/** **/
/****************************************************************************/
#define EYECAST (char huge *)
/* -------------------------------- */
/* Definitions and API structures : */
/* -------------------------------- */
typedef unsigned char Byte;
typedef signed short Word;
typedef unsigned long Long;
typedef struct
{
Word Use_Key;
Byte Key[8];
}
DES_MODE;
typedef struct
{
Word ModAd; /* Moduleaddress EYE */
Word Register; /* Memory register adress */
Word Value; /* Memory value */
Byte Reserved[4];
}
EYE_MODE;
typedef union
{
DES_MODE Des;
EYE_MODE Eye;
}
HARDWARE;
typedef struct hl_api
{
Byte API_Version_ID[2]; /* Version */
Word API_Options[2]; /* API Optionflags */
Word ModID; /* Modul-ID (EYE = 0...) */
HARDWARE Module; /* Hardware type */
void far *Data; /* Pointer to cipher data */
Word Bcnt; /* Number of blocks */
Word Function; /* Function number */
Word Status; /* Actual status */
Word Remote; /* Remote or local?? */
Word Port; /* Port address if local */
Word Speed; /* Speed of port if local */
Word NetUsers; /* Current Logins (HLSERVER) */
Byte ID_Ref[8]; /* Referencestring */
Byte ID_Verify[8]; /* Encrypted ID_Ref */
Long Task_ID; /* Multitasking program ID */
Byte Reserved[200]; /* Reserved area */
}
HL_API;
/* ------------- */
/* Module-ID's : */
/* ------------- */
#define EYE_DONGLE 0 /* Hardlock E-Y-E */
#define DES_DONGLE 1 /* FAST DES */
/* --------------------- */
/* API function calls : */
/* --------------------- */
#define API_INIT 0 /* Init API structure */
#define API_DOWN 1 /* Free API structure */
#define API_FORCE_DOWN 31 /* Force deinintialization */
#define API_MULTI_SHELL_ON 2 /* MTS is enabled */
#define API_MULTI_SHELL_OFF 3 /* MTS is disabled */
#define API_MULTI_ON 4 /* Enable MTS */
#define API_MULTI_OFF 5 /* Disable MTS */
#define API_AVAIL 6 /* Dongle available? */
#define API_LOGIN 7 /* Login dongle server */
#define API_LOGOUT 8 /* Logout dongle server */
#define API_INFO 9 /* Get API informations */
/* --------------------------- */
/* Data and memory functions : */
/* --------------------------- */
#define API_KEYE 11 /* Use KEYE for encryption */
#define API_READ 20 /* Read one word of dongle EEPROM */
#define API_WRITE 21 /* Write one word of dongle EEPROM */
#define API_READ_BLOCK 23 /* Read EEPROM in one block */
#define API_WRITE_BLOCK 24 /* Write EEPROM in one block */
#define API_GET_ID_KEY 30 /* Encrypt ID_Ref to ID_Verify */
#define API_ABORT 53 /* Critical Error Abort */
/* -------------------- */
/* Dongle access mode : */
/* -------------------- */
#define LOCAL_DEVICE 1 /* Query local HL only */
#define NET_DEVICE 2 /* Query remote HL only */
#define DONT_CARE 3 /* Query local or remote HL */
/* ------------------ */
/* API Status Codes : */
/* ------------------ */
#define STATUS_OK 0 /* API call was succesfull */
#define NOT_INIT 1 /* DONGLE not initialized */
#define ALREADY_INIT 2 /* Already initialized */
#define UNKNOWN_DONGLE 3 /* Device not supported */
#define UNKNOWN_FUNCTION 4 /* Function not supported */
#define NO_DONGLE 7 /* No device available */
#define NETWORK_ERROR 8 /* A network error occured */
#define NO_ACCESS 9 /* No device available */
#define INVALID_PARAM 10 /* A wrong parameter occured */
#define VERSION_MISMATCH 11 /* HL-Server not API version */
#ifdef __cplusplus
extern "C" {
#endif
/* --------------------- */
/* Function prototypes : */
/* --------------------- */
static int CALL_API (HL_API far *as);
Word far HL_LOGIN (Word ModAd, Word Access, char * RefKey, char * VerKey);
Word far HL_LOGOUT (void);
Word far HL_AVAIL (void);
Word far HL_PORTINF (void);
Word far HL_ACCINF (void);
Word far HL_USERINF (void);
Word far HL_MAXUSER (void);
Word far HL_MEMINF (void);
Word far HL_CODE (void far *Data, Word Count);
Word far HL_WRITE (Word Register, Word Value);
Word far HL_READ (Word Register, int far *Value);
char far * HL_GET_ID (char * id_ref);
Word far HL_READBL (char * Eeprom);
Word far HL_WRITEBL (char * Eeprom);
Word far HL_ABORT (void);
Word far HL_VERSION (void);
/****************************************************************************/
/****************************************************************************/
/* The following functions map the old Hardlock Calls on the new API. These */
/* functions are defined only for compatibility reasons. */
/* !!! Don't mix old and new functions. Don't use if it is not necessary.!!!*/
/****************************************************************************/
/****************************************************************************/
void far HL_ON (int Port, Word ModAd);
void far HL_OFF (int Port);
int far K_EYE (int Port, char huge *Inp, int BlkCnt);
void far HL_WR (int Port, int Register, Word Val);
Word far HL_RD (int Port, int Register);
void far INT_ON (void);
void far INT_OFF (void);
#ifdef __cplusplus
}
#endif
#endif

142
include/hlprot.c Executable file

@ -0,0 +1,142 @@
/*
@(SH) Funzioni per i controlli sulla chiave di protezione
--------------------------------------------------------------------------------
@(H) 2.3.01.176 09/03/93 Bonazzi Implementazione demo e formazione
@(H) 2.3.01.178 09/03/93 Bonazzi Implementazione EYE-API in DOS
*/
#include "ccommon.h"
#include "libdefs.h"
Word ModAd = 26952, Port = 0, SerNo = -1;
/* @(!) 2.3.01.176 */
BOOLEAN demoflag = FALSE, formflag = FALSE;
/* @(:) 2.3.01.176 */
/*
@(%) HL_Port LIBDEFS
@(ID)
Ricerca la chiave di protezione.
@(FD)
@(IN)
Restituisce l'indirizzo della porta parallela ove ha trovato la chiave di prot.
@(FN)
*/
#ifndef DOS
Word Hl_Port(ModAd)
Word ModAd; /* indirizzo del modulo */
{
Byte Dummy[10];
Word n, PortAdr[3];
PortAdr[0] = 0x3BC;
PortAdr[1] = 0x378;
PortAdr[2] = 0x278;
INT_OFF();
for(n = 0; n < 3; n++)
{
strcpy(Dummy, "HARDLOCK");
HL_ON(PortAdr[n], ModAd);
if(K_EYE(PortAdr[n], EYECAST Dummy, HLBLOCK))
if(K_EYE(PortAdr[n], EYECAST Dummy, HLBLOCK))
if(!strncmp("HARDLOCK", Dummy, 8))
{
HL_OFF(PortAdr[n]);
INT_ON();
return(PortAdr[n]);
}
HL_OFF(PortAdr[n]);
}
INT_ON();
return(0);
}
#endif
/*
@(%) getser LIBDEFS
@(ID)
Restituisce il numero di serie del cliente.
@(FD)
@(IN)
Utilizza la chiave di protezione.
@(FN)
*/
Word getser()
{
Word Val[4];
#ifndef DOS
BOOLEAN ok;
int i;
#endif
SerNo = -1;
/* @(!) 2.3.01.178 */
#ifdef DOS
if (HL_AVAIL() == STATUS_OK)
#else
/* @(:) 2.3.01.178 */
if (Port = Hl_Port(ModAd))
/* @(!) 2.3.01.178 */
#endif
/* @(:) 2.3.01.178 */
{
SerNo = 0;
/* @(!) 2.3.01.178 */
#ifdef DOS
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);
#else
/* @(:) 2.3.01.178 */
INT_OFF();
HL_ON(Port, ModAd);
Val[0] = HL_RD(Port, 0);
Val[1] = HL_RD(Port, 1);
Val[2] = HL_RD(Port, 2);
Val[3] = HL_RD(Port, 3);
HL_OFF(Port);
INT_ON();
INT_OFF();
HL_ON(Port, ModAd);
ok = K_EYE(Port, EYECAST &Val[0], HLBLOCK);
HL_OFF(Port);
INT_ON();
/* @(!) 2.3.01.178 */
#endif
/* @(:) 2.3.01.178 */
if (Val[0] == 0xFAE8)
{
SerNo = Val[1];
return(Val[1]);
}
else
return(0);
}
else
/* @(!) 2.3.01.176 */
{
#ifdef DOS
FILE *f = fopen("c:\\command.com", "r");
char s[4];
if (f == NULL) return(-1);
if (fseek(f, 46500L, SEEK_SET) != 0) return(-1);
if (fread(s, 1, 1, f) == -1) return(-1);
fclose(f);
if (*s != 'm') return(-1);
#endif
SerNo = 0;
demoflag = TRUE;
return(0);
}
/* @(:) 2.3.01.176 */
}

23
include/ioresult.c Executable file

@ -0,0 +1,23 @@
#include "ccommon.h"
/*
@(#) CIOResult COMMON
@(ID)
Legge il codice di errore e lo ritorna.
@(FD)
@(ISV)
res = intero contenente il codice di errore.
@(FSV)
*/
int CIOResult()
{
int res = errno ;
errno = NoErr ;
return(res) ;
}

37
include/keye.h Executable file

@ -0,0 +1,37 @@
#ifdef __cplusplus
extern "C" {
#endif
#ifdef DOS
typedef unsigned char Byte;
typedef unsigned int Word;
typedef unsigned long Long;
#define EYECAST (char huge *)
extern void far HL_ON (int Port, Word ModAd);
extern void far HL_OFF (int Port);
extern int far K_EYE (int Port, char huge *Inp, int BlkCnt);
extern void far HL_WR (int Port, int Register, Word Val);
extern Word far HL_RD (int Port, int Register);
extern void far INT_ON (void);
extern void far INT_OFF (void);
#else
#define INT_ON()
#define INT_OFF()
#define EYECAST
typedef unsigned long Long;
typedef unsigned short Word;
typedef unsigned char Byte;
void HL_ON (Word, Word); /* Activate the Hardlock */
void HL_OFF (Word); /* Deactivate the Hardlock */
Word HL_RD (Word, Word); /* Read from the EEProm */
void HL_WR (Word, Word, Word); /* Write to the EEProm */
Word K_EYE (Word, Byte *, Word); /* Encrypt Blocks */
#endif
#ifdef __cplusplus
};
#endif

127
include/libdefs.h Executable file

@ -0,0 +1,127 @@
/* @(!) 2.3.01.178 */
#ifdef DOS
#include "hlapi_c.h"
#else
#include "keye.h"
#endif
/* @(:) 2.3.01.178 */
#define MAXCKEY 5
#define MAXCLEN 10
#define MAXENTRYNAME 16
#define MAXTENTRY 48
/* @(!) 2.3.01.temp */
#define MAXENTRYSIZE 4096
/* @(:) 2.3.01.temp */
#define MAXDISPCOLS 4
#define CONFFILE "conf.gen"
#ifdef DOS
#define HLBLOCK 1
/* @(!) 2.3.01.178 */
#define REFKEY "CAMPOKEY"
#define VERKEY "ìpÙˆ¬cê<"
/* @(:) 2.3.01.178 */
#else
#define HLBLOCK 2
#endif
/*
@(H) 2.3.00.10 24/09/91 Bonazzi Dichiarato numero di versione globale
@(H) 2.3.01.69 15/05/92 Bonazzi Modificato algoritmo di refresh delle finestre
@(H) 2.3.01.130 08/10/92 Bonazzi Corretto algoritmo lettura caratteri per >128
*/
typedef union
{
BOOLEAN b; /*tipo BL*/
int i; /*tipo I*/
word w; /*tipo U*/
byte by; /*tipo BY*/
long l; /*tipo E*/
DEC r; /*tipo R*/
char c; /*tipo C*/
TrDate d; /*tipo D*/
Str80 s; /*tipo A*/
} conftype;
#ifndef DOS
struct capentry {
/* @(!) 2.3.01.130 */
uchar key[MAXCKEY];
uchar str[MAXCLEN];
/* @(:) 2.3.01.130 */
char charcode;
};
#endif
struct keybar {
word id;
uchar key;
char *explic;
struct keybar *next;
struct keybar *prev;
/* @(!) 2.3.01.223 */
BOOLEAN nosusp;
/* @(:) 2.3.01.223 */
};
extern conftype _int_cf;
extern char _int_res[513];
extern uchar _int_s1[256];
/* @(!) 2.3.01.temp */
#ifdef M_I386
extern short _int_cnt[8];
#else
/* @(:) 2.3.01.temp */
extern int _int_cnt[8];
/* @(!) 2.3.01.temp */
#endif
/* @(:) 2.3.01.temp */
#ifndef XVT_OS
extern chtype boxstr[MAXBORDERS][6];
extern int termlines;
extern int nwin;
extern int worder[MAXWIN];
#endif
extern BOOLEAN insstate;
extern BOOLEAN retins;
extern Word ModAd;
extern Word Port;
extern Word SerNo;
extern char *modname[];
#ifndef XVT_OS
extern int dispcol[MAXDISPCOLS][2];
#endif
extern char *keybarstr;
/* @(!) 2.3.00.10 */
extern char vers[];
/* @(H) 2.3.00.10 */
/* @(!) 2.3.01.69 */
#ifndef XVT_OS
extern BOOLEAN border;
#endif
/* @(:) 2.3.01.69 */
/* @(!) 2.3.01.150 */
extern BOOLEAN flprassi;
/* @(:) 2.3.01.150 */
/* @(!) 2.3.01.158 */
extern BOOLEAN flaltmodins;
/* @(:) 2.3.01.158 */
/* @(!) 2.3.01.176 */
extern BOOLEAN demoflag;
extern BOOLEAN formflag;
/* @(:) 2.3.01.176 */
/* @(!) 2.3.01.325 aggiunto pre-prefisso */
extern Str80 __ptprf;
/* @(:) 2.3.01.325 */
int setblock(int, BOOLEAN);
/* @(!) 2.3.01.130 */
char *custgetcap(uchar *, uchar *, int);
void readkeysdef (uchar *, struct capentry *);
int gettdef ( char *, uchar *);
/* @(:) 2.3.01.130 */
void initctab(struct capentry *);
void createaut (struct capentry *);
void putconf(int, conftype *);
Word Hl_Port(Word);
Word getser(void);

101
include/mshell.h Executable file

@ -0,0 +1,101 @@
#ifndef __MSHELL_H
#define __MSHELL_H
#ifdef XVT_OS
#ifdef __cplusplus
extern "C" {
#endif
#if XVT_OS == XVT_OS_NOTUSED
#define ALIGNSIZE sizeof(double)
#define CALCSIZE(x) ((((x) + (ALIGNSIZE - 1)) / ALIGNSIZE) * ALIGNSIZE)
#define malloc(a) win_malloc((a))
#define realloc(a,b) win_realloc((a), (b))
#define free(a) win_free((a))
#define calloc(a,b) win_calloc((a), (b))
#define strdup(a) win_strdup((a))
void setmemsize(long);
char* win_malloc(size_t);
char* win_realloc(char*, size_t);
void win_free(char*);
char* win_calloc(size_t, size_t);
char* win_strdup(char*);
#else
/*
#define malloc(a) xvt_fmalloc((a))
#define realloc(a,b) xvt_frealloc((a), (b))
#define free(a) xvt_ffree((a))
#define calloc(a,b) xvt_calloc((a), (b))
#define strdup(a) xvt_strdup((a))
#define setmemsize(a)
char *xvt_calloc(size_t, size_t);
char *xvt_strdup(char*);
*/
#endif
#ifdef __cplusplus
};
#endif
#else
#define size_t unsigned
#define MEMLIST
#define MEMWHERE
/* interface functions */
unsigned long memused(void);
void memdisplay(FILE *);
/* interface macros */
#define ALIGNSIZE sizeof(double)
#define CALCSIZE(x) ((((x) + (ALIGNSIZE - 1)) / ALIGNSIZE) * ALIGNSIZE)
/* interface functions to access only through macros */
#ifdef MEMWHERE
#ifdef __cplusplus
extern "C" {
#endif
char *memalloc(size_t, char *, int);
char *memrealloc(char *, size_t, char *, int);
void memfree(char *, char *, int);
char *memcalloc(size_t, size_t, char *, int);
char *memstrdup(char *, char *, int);
#else
char *memalloc(size_t);
char *memrealloc(char *);
void memfree(char *);
char *memcalloc(size_t, size_t);
char *memstrdup(char *);
#ifdef __cplusplus
};
#endif
#endif
/* Interface macros */
#ifndef __MSHELL__
#ifdef MEMWHERE
#define malloc(a) memalloc((a), __FILE__, __LINE__)
#define realloc(a,b) memrealloc((a), (b), __FILE__, __LINE__)
#define free(a) memfree((a), __FILE__, __LINE__)
#define calloc(a,b) memcalloc((a), (b), __FILE__, __LINE__)
#define strdup(a) memstrdup((a), __FILE__, __LINE__)
#else
#define malloc(a) memalloc((a))
#define realloc(a,b) memrealloc((a), (b))
#define free(a) memfree((a))
#define calloc(a,b) memcalloc((a), (b))
#define strdup(a) memstrdup((a))
#endif
#endif
#endif /* XVT_OS */
#endif /* __MSHELL_H */

20
include/tmpfname.c Executable file

@ -0,0 +1,20 @@
#include <malloc.h>
#include <stdio.h>
#include <string.h>
/*
@(H) 2.3.01.316 14/3/95 Vignali Gestione nomi temporanei intelligente
*/
/* @(!) 2.3.01.316 */
void tmpfname(p,n)
char *p;
char *n;
{
char *pp;
pp = (char *) tempnam("/tmp/",n);
strcpy(p,pp);
free((void *) pp);
}
/* @(:) 2.3.01.316 */

16
include/upstring.c Executable file

@ -0,0 +1,16 @@
#include "ccommon.h"
char *CUpString(s)
char *s; /* stringa da trasformare in maiuscolo */
{
char *s1 = s;
while (*s1)
{
*s1 = UPCASE(*s1);
s1++;
}
return(s);
}