1995-01-12 11:04:30 +00:00
|
|
|
/*
|
1995-01-12 11:42:58 +00:00
|
|
|
@(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
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
*/
|
1995-01-12 11:04:30 +00:00
|
|
|
|
|
|
|
#ifndef __CSORT_H
|
|
|
|
#define __CSORT_H
|
|
|
|
|
|
|
|
#ifndef __CCOMMON_H
|
1995-01-12 11:42:58 +00:00
|
|
|
#include "ccommon.h"
|
1995-01-12 11:04:30 +00:00
|
|
|
#endif
|
|
|
|
#ifndef __CCUSTIO_H
|
1995-01-12 11:42:58 +00:00
|
|
|
#include "ccustio.h"
|
1995-01-12 11:04:30 +00:00
|
|
|
#endif
|
|
|
|
#include "/usr/include/isam.h"
|
|
|
|
|
|
|
|
#define NOFLDS 10
|
|
|
|
#define MOSTMEM 51200
|
|
|
|
#define LEASTMEM 10240
|
|
|
|
#define MaxFields 100
|
|
|
|
#define MKFields 10
|
|
|
|
#define MaxKeys 8
|
|
|
|
#define MAXKEYS 8
|
|
|
|
|
|
|
|
typedef char FieldName[12] ;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char SysName[42] __PACKED__ ;
|
|
|
|
RecNoType EOD __PACKED__ ;
|
|
|
|
RecNoType EOX __PACKED__ ;
|
|
|
|
unsigned short LenR __PACKED__ ;
|
|
|
|
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
|
|
|
|
unsigned short RecOff __PACKED__ ;
|
|
|
|
} RecFieldDes ;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
word DupKeys __ALIGNED__ ;
|
|
|
|
byte NkFields __ALIGNED__ ;
|
|
|
|
byte FieldSeq[MKFields] __PACKED__ ;
|
|
|
|
byte FromCh[MKFields] __PACKED__ ;
|
|
|
|
byte ToCh[MKFields] __PACKED__ ;
|
|
|
|
} KeyDes ;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
short NFields __PACKED__ ;
|
|
|
|
RecFieldDes Fd[MaxFields] __PACKED__ ;
|
|
|
|
byte SortFd[MaxFields] __PACKED__ ;
|
|
|
|
short NKeys __PACKED__ ;
|
|
|
|
KeyDes Ky[MaxKeys] __PACKED__ ;
|
|
|
|
} RecDes ;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
FileDes *d;
|
|
|
|
RecDes *r;
|
|
|
|
RecNoType RecNo;
|
|
|
|
short ln;
|
|
|
|
short ft;
|
|
|
|
short knum;
|
|
|
|
short newkey;
|
|
|
|
int mode;
|
|
|
|
struct keydesc k[MAXKEYS + 1];
|
|
|
|
} isdef ;
|
|
|
|
|
|
|
|
|
|
|
|
typedef isdef* isfdptr;
|
|
|
|
struct s_prm {
|
1995-01-12 11:42:58 +00:00
|
|
|
int rc_len;
|
|
|
|
struct {
|
|
|
|
int f_pos;
|
|
|
|
int f_len;
|
|
|
|
char ad;
|
|
|
|
|
|
|
|
} s_fld [NOFLDS];
|
|
|
|
};
|
|
|
|
struct bp {
|
|
|
|
char *rc;
|
|
|
|
/* @(!) 2.3.00.112 */
|
|
|
|
unsigned rbuf;
|
|
|
|
unsigned rdsk;
|
|
|
|
/* @(:) 2.3.00.112 */
|
|
|
|
};
|
1995-01-12 11:04:30 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
1995-01-12 11:42:58 +00:00
|
|
|
/*----------------------- FUNZIONI VISIBILI PRIMA PARTE ---------------------*/
|
1995-01-12 11:04:30 +00:00
|
|
|
|
1995-01-12 11:42:58 +00:00
|
|
|
int init_sort(struct s_prm *); /* Initialize the sort */
|
|
|
|
void sort(char *); /* Pass records to Sort */
|
|
|
|
char *sort_op(void); /* Retrieve sorted records */
|
|
|
|
void sort_stats(void); /* Display sort statistics */
|
1995-01-12 11:04:30 +00:00
|
|
|
|
1995-01-12 11:42:58 +00:00
|
|
|
/*----------------------- FUNZIONI VISIBILI SECONDA PARTE -------------------*/
|
1995-01-12 11:04:30 +00:00
|
|
|
|
1995-01-12 11:42:58 +00:00
|
|
|
void initsortfield (void);
|
|
|
|
int addsortfield (isfdptr, FieldName, int, int, char);
|
|
|
|
int finesortfield (isfdptr);
|
1995-01-12 11:04:30 +00:00
|
|
|
|
1995-01-12 11:42:58 +00:00
|
|
|
/* 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 non c'e' sufficiente memoria per procedere */
|
1995-01-12 11:04:30 +00:00
|
|
|
|
1995-01-12 11:42:58 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
1995-01-12 11:04:30 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
};
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
#endif /* __CSORT_H */
|