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
View 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 */

View File

@ -1,23 +1,3 @@
/*
@(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" #include "checks.h"
#ifdef DOS #ifdef DOS

81
include/ccustio.h Executable file
View 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
View 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 */

View File

@ -1,30 +1,10 @@
/*
@(SH) Funzioni per l'esecuzione di sort
@(VG$) PRIVATE
datisort : copia struttura del sort attivo
nsortfield : Numero campi definiti dal sort
sp : struttura dei parametri sort
totrcd : numero totale di record ordinati
no_seq : contatore sequenze
no_seq1 : contatore sequenze
bspace : spazio disponibile nel buffer
nrcds : numero di records nel buffer di sort
nrcds1 : numero di records nel buffer di sort
bf, bf1 : puntatori al buffer di sort
inbf : records variabili nel buffer di sort
sptr : puntatore al vettore dei puntatori ai buffer
init_sptr : puntatore al buffer appropriato
rcds_seq : sequenza record nel buffer di merge
fp1, fp2 : puntatori a file di lavoro per il sort
fdname : nome di lavoro del sort
f2name : nome di lavoro del sort
-------------------------------------------------------------------------------
@(H) 2.3.00.112 23/11/91 Bonazzi Corretta fine sort
@(H) 2.3.01.245 08/03/94 Soragna Corretto sort_op per 386
*/
#include "csort.h" #include "csort.h"
#ifdef __WATCOMC__
#include <malloc.h>
#include <io.h>
#else
#include <memory.h> #include <memory.h>
#endif
/*----------------------- STATIC PER PRIMA PARTE ----------------------------*/ /*----------------------- STATIC PER PRIMA PARTE ----------------------------*/
@ -72,15 +52,15 @@ void dummy(void);
/*----------------------- PRIMA PARTE ---------------------------------------*/ /*----------------------- PRIMA PARTE ---------------------------------------*/
/* /*
@(#) init_sort SORT @(#) init_sort SORT
@(ID) @(ID)
Inizializza le variabili globali per il sort. Inizializza le variabili globali per il sort.
@(FD) @(FD)
*/ */
int init_sort(prms) int init_sort(prms)
struct s_prm *prms; /* struttura di descrizione del sort */ struct s_prm *prms; /* struttura di descrizione del sort */
{ {
sp = prms; sp = prms;
if ((bf = appr_mem(&bspace)) != NULL) { if ((bf = appr_mem(&bspace)) != NULL) {
@ -97,24 +77,24 @@ struct s_prm *prms; /* struttura di descrizione del sort */
} }
/* /*
@(#) sort SORT @(#) sort SORT
@(ID) @(ID)
Funzione per l'input dei record da ordinare. Funzione per l'input dei record da ordinare.
@(FD) @(FD)
@(IN) @(IN)
La chiamata sort(char *) NULL) chiude la fase di input dei record. La chiamata sort(char *) NULL) chiude la fase di input dei record.
@(FN) @(FN)
*/ */
void sort(s_rcd) void sort(s_rcd)
char *s_rcd; /* buffer contenente il record da ordinare */ char *s_rcd; /* buffer contenente il record da ordinare */
{ {
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
if (inbf == nrcds) { /* if the sort buffer is full */ if (inbf == nrcds) { /* if the sort buffer is full */
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
qsort(init_sptr, inbf, sizeof (char *), sortcomp); qsort(init_sptr, inbf, sizeof (char *), sortcomp);
if (s_rcd) { /* if there are more records to sort */ if (s_rcd) { /* if there are more records to sort */
dumpbuff(); /* dump the buffer to a sort work file*/ dumpbuff(); /* dump the buffer to a sort work file*/
@ -144,88 +124,88 @@ char *s_rcd; /* buffer contenente il record da ordinare */
} }
} }
/* /*
@($) prep_merge SORT @($) prep_merge SORT
@(ID) @(ID)
Funzione per la preparazione del Merge. Funzione per la preparazione del Merge.
@(FD) @(FD)
@(ISV) @(ISV)
i = contatore. i = contatore.
rr = puntatore ad una struttura di sequenza (di lavoro). rr = puntatore ad una struttura di sequenza (di lavoro).
n_bfsz = ampiezza in byte del merge buffer. n_bfsz = ampiezza in byte del merge buffer.
@(FSV) @(FSV)
*/ */
static void prep_merge() static void prep_merge()
{ {
int i; int i;
struct bp *rr; struct bp *rr;
unsigned n_bfsz; unsigned n_bfsz;
memset(init_sptr, '\0', bspace); memset(init_sptr, '\0', bspace);
/* -------- merge buffer size ------ */ /* -------- merge buffer size ------ */
n_bfsz = bspace - no_seq * sizeof(struct bp); n_bfsz = bspace - no_seq * sizeof(struct bp);
/* ------ # rcds/seq in merge buffer ------- */ /* ------ # rcds/seq in merge buffer ------- */
rcds_seq = n_bfsz / no_seq / sp->rc_len; rcds_seq = n_bfsz / no_seq / sp->rc_len;
if (rcds_seq < 2) { if (rcds_seq < 2) {
/* ---- more sequence blocks than will fit in buffer, /* ---- more sequence blocks than will fit in buffer,
merge down ---- */ merge down ---- */
while (rcds_seq < 2) { while (rcds_seq < 2) {
FILE *hd; FILE *hd;
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
char wname[42]; /* sort work name */ char wname[42]; /* sort work name */
fp2 = wopen(f2name); /* open a sort work file */ fp2 = wopen(f2name); /* open a sort work file */
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
merge(); /* binary merge */ merge(); /* binary merge */
hd = fp1; /* swap fds */ hd = fp1; /* swap fds */
fp1 = fp2; fp1 = fp2;
fp2 = hd; fp2 = hd;
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
strcpy(wname, fdname); strcpy(wname, fdname);
strcpy(fdname, f2name); strcpy(fdname, f2name);
strcpy(f2name, wname); strcpy(f2name, wname);
fclose(fp2); fclose(fp2);
unlink(f2name); unlink(f2name);
fp2 = NULL; fp2 = NULL;
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
nrcds *= 2; nrcds *= 2;
/* ------ adjust number of sequence ------ */ /* ------ adjust number of sequence ------ */
no_seq = (no_seq + 1) / 2; no_seq = (no_seq + 1) / 2;
n_bfsz = bspace - no_seq * sizeof(struct bp); n_bfsz = bspace - no_seq * sizeof(struct bp);
rcds_seq = n_bfsz / no_seq / sp->rc_len; rcds_seq = n_bfsz / no_seq / sp->rc_len;
} }
} }
bf1 = init_sptr; bf1 = init_sptr;
rr = (struct bp *) init_sptr; rr = (struct bp *) init_sptr;
bf1 += no_seq * sizeof(struct bp); bf1 += no_seq * sizeof(struct bp);
bf = bf1; bf = bf1;
/* fill the merge buffer with records from all sequences */ /* fill the merge buffer with records from all sequences */
for (i = 0; i < no_seq; i++) { for (i = 0; i < no_seq; i++) {
fseek(fp1, (long) i * ((long) nrcds * sp->rc_len), 0); fseek(fp1, (long) i * ((long) nrcds * sp->rc_len), 0);
/* ------ read them all at once ------ */ /* ------ read them all at once ------ */
/* @(!) 2.3.00.112 modificata fread(bf1, rcds_seq * sp->rc_len, 1, fp1); */ /* @(!) 2.3.00.112 modificata fread(bf1, rcds_seq * sp->rc_len, 1, fp1); */
fread(bf1, sp->rc_len, rcds_seq, fp1); fread(bf1, sp->rc_len, rcds_seq, fp1);
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
rr->rc = bf1; rr->rc = bf1;
/* --- the last seq has fewer rcds than the rest --- */ /* --- the last seq has fewer rcds than the rest --- */
if (i == no_seq-1) { if (i == no_seq-1) {
if (totrcd % nrcds > rcds_seq) { if (totrcd % nrcds > rcds_seq) {
rr->rbuf = rcds_seq; rr->rbuf = rcds_seq;
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
rr->rdsk = (unsigned) (totrcd % nrcds) - rcds_seq; rr->rdsk = (unsigned) (totrcd % nrcds) - rcds_seq;
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
} }
else { else {
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
rr->rbuf = (unsigned) (totrcd % nrcds); rr->rbuf = (unsigned) (totrcd % nrcds);
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
rr->rdsk = 0; rr->rdsk = 0;
} }
} }
@ -235,7 +215,7 @@ for (i = 0; i < no_seq; i++) {
} }
rr++; rr++;
bf1 += rcds_seq * sp->rc_len; bf1 += rcds_seq * sp->rc_len;
} }
} }
/* @(!) 2.3.01.245 */ /* @(!) 2.3.01.245 */
@ -248,7 +228,7 @@ for (i = 0; i < no_seq; i++) {
numerose. Probabilmente evita, in fase di compilazione, che vengano numerose. Probabilmente evita, in fase di compilazione, che vengano
creati indirizzi strani, oppure in fase di esecuzione, che vengano creati indirizzi strani, oppure in fase di esecuzione, che vengano
reperite zone di memoria che non c'entrano per nulla. reperite zone di memoria che non c'entrano per nulla.
*/ */
void dummy() void dummy()
{ {
} }
@ -256,40 +236,40 @@ void dummy()
/* /*
@($) merge SORT @($) merge SORT
@(ID) @(ID)
Effettua un merge. Effettua un merge.
E' un merge binario di records dalla sequenza fp1 in fp2. E' un merge binario di records dalla sequenza fp1 in fp2.
@(FD @(FD
@(ISV) @(ISV)
i = contatore. i = contatore.
needy,needx = se true necessita un record da (x/y). needy,needx = se true necessita un record da (x/y).
xcnt,ycnt = numero di records lasciati in ogni sequenza. xcnt,ycnt = numero di records lasciati in ogni sequenza.
x,y = contatori per le sequenze. x,y = contatori per le sequenze.
adx,ady = indirizzi sul disco delle sequenze di record. adx,ady = indirizzi sul disco delle sequenze di record.
ysptr = stringa di lavoro. ysptr = stringa di lavoro.
@(FSV) @(FSV)
*/ */
static void merge() static void merge()
{ {
int i; int i;
int needy, needx; /* true = need a rcd from (x/y) */ int needy, needx; /* true = need a rcd from (x/y) */
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
unsigned xcnt, ycnt; /* # rcds left each sequence */ unsigned xcnt, ycnt; /* # rcds left each sequence */
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
int x, y; /* sequence counters */ int x, y; /* sequence counters */
long adx, ady; /* sequence record disk addresses */ long adx, ady; /* sequence record disk addresses */
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
char *ysptr = init_sptr + sp->rc_len; char *ysptr = init_sptr + sp->rc_len;
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
/* --- the two sets of sequences are x and y ----- */ /* --- the two sets of sequences are x and y ----- */
fseek (fp2, 0L, 0); fseek (fp2, 0L, 0);
@ -298,10 +278,10 @@ static void merge()
y++; y++;
ycnt = ycnt =
y == no_seq ? 0 : y == no_seq - 1 ? y == no_seq ? 0 : y == no_seq - 1 ?
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
(unsigned) (totrcd % nrcds) : nrcds; (unsigned) (totrcd % nrcds) : nrcds;
xcnt = y == no_seq ? (unsigned) (totrcd % nrcds) : nrcds; xcnt = y == no_seq ? (unsigned) (totrcd % nrcds) : nrcds;
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
adx = (long) x * (long) nrcds * sp->rc_len; adx = (long) x * (long) nrcds * sp->rc_len;
ady = adx + (long) nrcds * sp ->rc_len; ady = adx + (long) nrcds * sp ->rc_len;
needy = needx = 1; needy = needx = 1;
@ -315,25 +295,25 @@ static void merge()
if (needy && ycnt) { /* need a rcd from y? */ if (needy && ycnt) { /* need a rcd from y? */
fseek(fp1, ady, 0); fseek(fp1, ady, 0);
ady += sp->rc_len; ady += sp->rc_len;
/* @(!) 2.3.00.112 modificata fread(init_sptr+sp->rc_len, sp->rc_len, 1, fp1); */ /* @(!) 2.3.00.112 modificata fread(init_sptr+sp->rc_len, sp->rc_len, 1, fp1); */
fread(ysptr, sp->rc_len, 1, fp1); fread(ysptr, sp->rc_len, 1, fp1);
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
needy = 0; needy = 0;
} }
if (xcnt || ycnt) { /* if anything is left */ if (xcnt || ycnt) { /* if anything is left */
/* ---- compare the two sequences --- */ /* ---- compare the two sequences --- */
/* @(!) 2.3.00.112 modificata if (!ycnt || (xcnt && (sortcomp(&init_sptr, &init_sptr + sp->rc_len)) < 0)) { */ /* @(!) 2.3.00.112 modificata if (!ycnt || (xcnt && (sortcomp(&init_sptr, &init_sptr + sp->rc_len)) < 0)) { */
if (!ycnt || (xcnt && (sortcomp(&init_sptr, &ysptr)) < 0)) { if (!ycnt || (xcnt && (sortcomp(&init_sptr, &ysptr)) < 0)) {
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
/* ----- record from x is lower ---- */ /* ----- record from x is lower ---- */
fwrite(init_sptr, sp->rc_len, 1, fp2); fwrite(init_sptr, sp->rc_len, 1, fp2);
--xcnt; --xcnt;
needx = 1; needx = 1;
} }
else if (ycnt) { /* record from y is lower */ else if (ycnt) { /* record from y is lower */
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
fwrite(ysptr, sp->rc_len, 1, fp2); fwrite(ysptr, sp->rc_len, 1, fp2);
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
--ycnt; --ycnt;
needy = 1; needy = 1;
} }
@ -342,66 +322,68 @@ static void merge()
} }
} }
/* /*
@($) dumpbuff SORT @($) dumpbuff SORT
@(ID) @(ID)
Copia il buffer di sort nel file di lavoro. Copia il buffer di sort nel file di lavoro.
@(FD) @(FD)
@(ISV) @(ISV)
i = contatore. i = contatore.
@(FSV) @(FSV)
*/ */
static void dumpbuff() static void dumpbuff()
{ {
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
unsigned i; unsigned i;
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
if (fp1 == NULL) if (fp1 == NULL)
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
fp1 = wopen(fdname); fp1 = wopen(fdname);
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
sptr = (char **) init_sptr; sptr = (char **) init_sptr;
for (i = 0; i < inbf; i++) { for (i = 0; i < inbf; i++) {
fwrite(*(sptr + i), sp->rc_len, 1, fp1); fwrite(*(sptr + i), sp->rc_len, 1, fp1);
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
*(sptr + i) = 0; *(sptr + i) = 0;
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
} }
inbf = 0; inbf = 0;
} }
/* /*
@($) wopen SORT @($) wopen SORT
@(ID) @(ID)
Apre un file di lavoro temporaneo (per il sort). Apre un file di lavoro temporaneo (per il sort).
@(FD) @(FD)
@(ISV) @(ISV)
fp = puntatore al file temporaneo. fp = puntatore al file temporaneo.
s = stringa di formato. s = stringa di formato.
n = numero del file. n = numero del file.
@(FSV) @(FSV)
*/ */
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
static FILE *wopen(name) static FILE *wopen(name)
char *name; /* nome del file temporaneo */ char *name; /* nome del file temporaneo */
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
{ {
FILE *fp; FILE *fp;
char s[42]; char s[42];
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
static int n = 0; static int n = 0;
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
sprintf(s, "srt%03d", ++n); /* @(!) 2.3.00.316 */
sprintf(s, "srt%02d", ++n);
/* @(:) 2.3.00.316 */
TMPFNAME(name,s); TMPFNAME(name,s);
#ifdef DOS #ifdef DOS
if ((fp = fopen(name, "wb+")) == NULL) { if ((fp = fopen(name, "wb+")) == NULL) {
@ -417,47 +399,47 @@ char *name; /* nome del file temporaneo */
#endif #endif
} }
return fp; return fp;
} }
/* /*
@(#) sort_op SORT @(#) sort_op SORT
@(ID) @(ID)
Ritorna il puntatore al primo record non ancora elaborato nella sequenza ordinata. Ritorna il puntatore al primo record non ancora elaborato nella sequenza ordinata.
@(FD) @(FD)
@(ISV) @(ISV)
j = e' true se una qualche sequenza contiene ancora dei records. j = e' true se una qualche sequenza contiene ancora dei records.
i = contatore. i = contatore.
k,nrd,l = variabili di lavoro. k,nrd,l = variabili di lavoro.
rr = variabile di lavoro. rr = variabile di lavoro.
r1 = variabile di lavoro. r1 = variabile di lavoro.
rtn = indirizzo del buffer da ritornare. rtn = indirizzo del buffer da ritornare.
ad,tr = variabili di lavoro. ad,tr = variabili di lavoro.
@(FSV) @(FSV)
@(FN) @(FN)
Se la funzione sort_op ritorna NULL non ci sono piu' records nella sequenza ordinata. Se la funzione sort_op ritorna NULL non ci sono piu' records nella sequenza ordinata.
@(FN) @(FN)
*/ */
char *sort_op() char *sort_op()
{ {
int j = 0; int j = 0;
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
unsigned i, k, nrd, l; unsigned i, k, nrd, l;
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
struct bp *rr; struct bp *rr;
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
static unsigned r1 = 0; static unsigned r1 = 0;
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
char *rtn; char *rtn;
long ad, tr; long ad, tr;
@ -466,13 +448,13 @@ char *sort_op()
sptr = (char **) init_sptr; sptr = (char **) init_sptr;
if (no_seq < 2) { if (no_seq < 2) {
/* -- with only 1 sequence, mo merge has been done -- */ /* -- with only 1 sequence, mo merge has been done -- */
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
if (r1 == (unsigned) totrcd) { if (r1 == (unsigned) totrcd) {
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
if (init_sptr != NULL) free(init_sptr); if (init_sptr != NULL) free(init_sptr);
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
init_sptr = NULL; init_sptr = NULL;
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
fp1 = fp2 = NULL; fp1 = fp2 = NULL;
r1 = 0; r1 = 0;
return NULL; return NULL;
@ -483,25 +465,25 @@ char *sort_op()
rr = (struct bp *) init_sptr; rr = (struct bp *) init_sptr;
for (i = 0; i < no_seq; i++) for (i = 0; i < no_seq; i++)
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
j |= (int) (rr + i)->rbuf | (rr + i)->rdsk; j |= (int) (rr + i)->rbuf | (rr + i)->rdsk;
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
/* -- j will be true if any sequence still has records - */ /* -- j will be true if any sequence still has records - */
if (!j) if (!j)
{ {
fclose(fp1); /* none left */ fclose(fp1); /* none left */
unlink(fdname); unlink(fdname);
/* @(!) 2.3.00.112 eliminata if (fp2) */ /* @(!) 2.3.00.112 eliminata if (fp2) */
/* @(!) 2.3.00.112 eliminata { */ /* @(!) 2.3.00.112 eliminata { */
/* @(!) 2.3.00.112 eliminata fclose(fp2); */ /* @(!) 2.3.00.112 eliminata fclose(fp2); */
/* @(!) 2.3.00.112 eliminata unlink(f2name); */ /* @(!) 2.3.00.112 eliminata unlink(f2name); */
/* @(!) 2.3.00.112 eliminata } */ /* @(!) 2.3.00.112 eliminata } */
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
if (init_sptr != NULL) free(init_sptr); if (init_sptr != NULL) free(init_sptr);
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
init_sptr = NULL; init_sptr = NULL;
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
fp1 = fp2 = NULL; fp1 = fp2 = NULL;
r1 = 0; r1 = 0;
return NULL; return NULL;
@ -524,22 +506,22 @@ char *sort_op()
/* ---- the sequence got empty ---- */ /* ---- the sequence got empty ---- */
/* --- so get some more if there are any --- */ /* --- so get some more if there are any --- */
rtn = bf + k * rcds_seq * sp->rc_len; rtn = bf + k * rcds_seq * sp->rc_len;
/* @(!) 2.3.01.245 */ /* @(!) 2.3.01.245 */
dummy(); dummy();
/* @(:) 2.3.01.245 */ /* @(:) 2.3.01.245 */
memcpy(rtn, (rr + k)->rc - sp->rc_len, sp->rc_len); memcpy(rtn, (rr + k)->rc - sp->rc_len, sp->rc_len);
(rr + k)->rc = rtn + sp->rc_len; (rr + k)->rc = rtn + sp->rc_len;
if ((rr + k)->rdsk != 0) { if ((rr + k)->rdsk != 0) {
l = ((rcds_seq-1) < (rr+k)->rdsk) ? rcds_seq-1 : (rr+k)->rdsk; l = ((rcds_seq-1) < (rr+k)->rdsk) ? rcds_seq-1 : (rr+k)->rdsk;
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
nrd = k == no_seq - 1 ? (unsigned) (totrcd % nrcds) : nrcds; nrd = k == no_seq - 1 ? (unsigned) (totrcd % nrcds) : nrcds;
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
tr = (long) ((k * nrcds + (nrd - (rr + k)->rdsk))); tr = (long) ((k * nrcds + (nrd - (rr + k)->rdsk)));
ad = tr * sp->rc_len; ad = tr * sp->rc_len;
fseek(fp1, ad, 0); fseek(fp1, ad, 0);
/* @(!) 2.3.00.112 modificata fread(rtn + sp->rc_len, l * sp->rc_len, 1, fp1); */ /* @(!) 2.3.00.112 modificata fread(rtn + sp->rc_len, l * sp->rc_len, 1, fp1); */
fread(rtn + sp->rc_len, sp->rc_len, l, fp1); fread(rtn + sp->rc_len, sp->rc_len, l, fp1);
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
(rr + k)->rbuf = l; (rr + k)->rbuf = l;
(rr + k)->rdsk -= l; (rr + k)->rdsk -= l;
} }
@ -547,29 +529,29 @@ char *sort_op()
memset((rr + k)->rc, 127, sp->rc_len); memset((rr + k)->rc, 127, sp->rc_len);
} }
return rtn; return rtn;
} }
/* /*
@(#) sort_stats SORT @(#) sort_stats SORT
@(ID) @(ID)
Visualizza la statistica sul sort. Visualizza la statistica sul sort.
@(FD) @(FD)
*/ */
void sort_stats() void sort_stats()
{ {
#ifndef XVT_OS #ifndef XVT_OS
printf("\n\r\n\r\n\rRecord Length = %d",sp->rc_len); printf("\n\r\n\r\n\rRecord Length = %d",sp->rc_len);
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
printf("\n\r%u records sorted",totrcd); printf("\n\r%u records sorted",totrcd);
printf("\n\r%u sequence",no_seq); printf("\n\r%u sequence",no_seq);
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
if (no_seq1 != 1) putchar('s'); if (no_seq1 != 1) putchar('s');
printf("\n\r%u characters of sort buffer", bspace); printf("\n\r%u characters of sort buffer", bspace);
/* @(!) 2.3.00.112 */ /* @(!) 2.3.00.112 */
printf("\n\r%u records per buffer\n\n",nrcds); printf("\n\r%u records per buffer\n\n",nrcds);
/* @(:) 2.3.00.112 */ /* @(:) 2.3.00.112 */
#else #else
message_box( message_box(
"Record length = %d\n" "Record length = %d\n"
@ -580,27 +562,27 @@ void sort_stats()
sp->rc_len, totrcd, no_seq, bspace, nrcds sp->rc_len, totrcd, no_seq, bspace, nrcds
); );
#endif #endif
} }
/* /*
@($) appr_mem SORT @($) appr_mem SORT
@(ID) @(ID)
Alloca memoria per un buffer. Alloca memoria per un buffer.
@(FD) @(FD)
@(ISV) @(ISV)
buff = buffer di memoria allocato. buff = buffer di memoria allocato.
@(FSV) @(FSV)
@(IN) @(IN)
Se puo' alloca MOSTMEM altrimenti ne alloca quanto puo', Se puo' alloca MOSTMEM altrimenti ne alloca quanto puo',
non scendendo mai sotto il minimo LEASTMEM non scendendo mai sotto il minimo LEASTMEM
@(FN) @(FN)
*/ */
static char *appr_mem(h) static char *appr_mem(h)
unsigned *h; /* puntatore alla quantita' di byte allocati */ unsigned *h; /* puntatore alla quantita' di byte allocati */
{ {
char *buff = NULL; char *buff = NULL;
@ -613,27 +595,27 @@ unsigned *h; /* puntatore alla quantita' di byte allocati */
} }
/* /*
@($) sortcomp SORT @($) sortcomp SORT
@(ID) @(ID)
Esegue i confronti per il sort ed il merge. Esegue i confronti per il sort ed il merge.
@(FD) @(FD)
@(ISV) @(ISV)
i = contatore. i = contatore.
k = risultato della comparazione. k = risultato della comparazione.
@(FSV) @(FSV)
@(IN) @(IN)
Ritorna un intero < 0 se a < b Ritorna un intero < 0 se a < b
0 se a = b 0 se a = b
> 0 se a > b > 0 se a > b
@(FN) @(FN)
*/ */
static int sortcomp(a,b) static int sortcomp(a,b)
char **a; char **b; /* puntatori ai puntatori ai record da confrontare */ char **a; char **b; /* puntatori ai puntatori ai record da confrontare */
{ {
int i, k; int i, k;
@ -677,77 +659,17 @@ char **a; char **b; /* puntatori ai puntatori ai record da confrontare */
/*---------------------------- SECONDA PARTE --------------------------------*/ /*---------------------------- SECONDA PARTE --------------------------------*/
/* /*
@(#) initsortfield SORT @(#) initsortfield SORT
@(ID) @(ID)
Definizione di sort per un record ISAM. Definizione di sort per un record ISAM.
@(FD) @(FD)
*/ */
void initsortfield () void initsortfield ()
{ {
nsortfield = datisort.s_fld[0].f_pos = 0; /* sort su nessun campo */ nsortfield = datisort.s_fld[0].f_pos = 0; /* sort su nessun campo */
} }
/*
@(#) addsortfield SORT
@(ID)
Aggiunge campi alla descrizione.
@(FD)
@(ISV)
i = variablie di lavoro.
n = variablie di lavoro.
@(FSV)
*/
int addsortfield (isfd,ncampo,da,a,ad)
isfdptr isfd; /* puntatore al descrittore del file ISAM */
FieldName ncampo; /* nome campo */
int da; /* carattere da cui considerare il campo per il sort */
int a; /* carattere fino al quale considerare il campo per il sort */
char ad; /* ordine crescente o decrescente */
{
int i,n;
if (((n = findfld(isfd->r, ncampo)) != -1) && (nsortfield < NOFLDS))
{
/* sostituito i con n in Fd[_].RecOff e Fd[_].len */
/* @(!) 2.3.01.temp */
datisort.s_fld[nsortfield].f_pos = (da==0) ? (isfd->r->Fd[n].RecOff + 1) : (isfd->r->Fd[n].RecOff+da);
datisort.s_fld[nsortfield].f_len = (a==0) ? (isfd->r->Fd[n].Len) : (a-da+1); /* carica FLDLEN */
datisort.s_fld[nsortfield].ad = ad; /* carica AD */
nsortfield++;
/* @(:) 2.3.01.temp */
return 0;
}
else return -1;
}
/*
@(#) finesortfield SORT
@(ID)
Chiude la descrizione del sort per i record ISAM.
@(FD)
@(IN)
Attenzione : questa funzione inizializza anche il sort.
@(FN)
*/
int finesortfield (isfd)
isfdptr isfd; /* puntatore al descrittore del file ISAM */
{
datisort.rc_len=isfd->d->LenR;
/* @(!) 2.3.01.temp */
if (nsortfield < NOFLDS)
datisort.s_fld[nsortfield].f_pos = 0; /* chiude l'elenco campi */
/* @(:) 2.3.01.temp */
return (init_sort (&datisort));
}
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View File

@ -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 #ifndef __CSORT_H
#define __CSORT_H #define __CSORT_H
#ifndef __CCOMMON_H #ifndef __CFILES_H
#include "ccommon.h" #include "cfiles.h"
#endif
#ifndef __CCUSTIO_H
#include "ccustio.h"
#endif
#ifndef __CISAM_H
#include "cisam.h"
#endif #endif
#define NOFLDS 10 #define NOFLDS 10
@ -70,8 +39,6 @@ extern "C" {
/*----------------------- FUNZIONI VISIBILI SECONDA PARTE -------------------*/ /*----------------------- FUNZIONI VISIBILI SECONDA PARTE -------------------*/
void initsortfield (void); 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 */ /* 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 */ /* ritorna 0 se tutto ok, -1 se chiamata piu' di NOFLDS volte dopo l'ultimo initsortfield */

13
include/fldtypes.h Executable file
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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);
}