189 lines
5.1 KiB
C
Executable File
189 lines
5.1 KiB
C
Executable File
/******************************************************************************
|
|
*
|
|
* Definitions for PI/open dynamic file convertor utility
|
|
*
|
|
* Module %M% Version %I% Date %H%
|
|
*
|
|
* (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved
|
|
* This is unpublished proprietary source code of Ardent Software Inc.
|
|
* The copyright notice above does not evidence any actual or intended
|
|
* publication of such source code.
|
|
*
|
|
*******************************************************************************
|
|
*
|
|
* Maintenence log - insert most recent change descriptions at top
|
|
*
|
|
* Date.... GTAR# WHO Description.........................................
|
|
* 10/14/98 23801 SAP Change copyrights.
|
|
* 05/17/96 18433 WSM Changes to allow conversion on any platform.
|
|
* 05/13/94 14011 ALC Minor changes to reflect changes to the convertor.
|
|
* 05/12/94 13934 ALC Changes for phase 2 version of file convertor.
|
|
* 03/29/94 13509 ALC Changes due to errors in oversize record handling.
|
|
* 10/21/93 12303 ALC Initial implementation
|
|
*
|
|
******************************************************************************/
|
|
|
|
|
|
/*
|
|
* Name segments for PI/open dynamic file manipulation
|
|
*/
|
|
#define PI_LH_MAINSUBFILE 0
|
|
#define PI_LH_OVFLSUBFILE 1
|
|
|
|
#define PI_NAME_FORMAT_MIPS "%s/ \b%u"
|
|
#define PI_NAME_FORMAT "%s/&$%u"
|
|
#define UV_NAME_FORMAT "%s/%s"
|
|
|
|
|
|
/*
|
|
* Constants used in file conversion
|
|
* HASH_TYPE_CNV - Conversion factor for hash function value
|
|
* SPLIT_OFFSET - Difference between PI/open and uniVerse split value
|
|
* PAGE_SZ - PI/open File page size in bytes
|
|
* HDR_OFFSET - Position of header on file
|
|
* UV_HDR - Size of uniVerse record header in bytes.
|
|
*/
|
|
#define HASH_TYPE_CNV 18
|
|
#define SPLIT_OFFSET 1
|
|
#define PAGE_SZ 1024
|
|
#define HDR_OFFSET 0
|
|
#define UV_HDR 12
|
|
|
|
|
|
/*
|
|
* Flags to indicate whether to read a full block or just the
|
|
* amount of data specified when doing a get_blk() call.
|
|
*/
|
|
#define BYTES_SPECIFIED 1
|
|
#define FILL_BLOCK 0
|
|
|
|
|
|
/*
|
|
* Type of current write block
|
|
*/
|
|
#define PRIMARY_WRTBLK 0
|
|
#define FIRST_OVFLOW_WRTBLK 1
|
|
#define OTHER_OVFLOW_WRTBLK 2
|
|
|
|
|
|
/*
|
|
* Position of write block in group chain for write_recblk() call
|
|
*/
|
|
#define MID_CHAIN 0
|
|
#define END_CHAIN 1
|
|
|
|
|
|
/*
|
|
* Macro's to simplify code
|
|
*/
|
|
#define min(A,B) ((A) < (B) ? (A) : (B))
|
|
|
|
|
|
/*
|
|
* Input block type
|
|
*/
|
|
#define NEW_GROUP 0
|
|
#define PRIMARY_RDBLK 1
|
|
#define OVERFLOW_RDBLK 2
|
|
#define NEW_BREC_CHAIN 3
|
|
#define FIRST_BIGREC_RDBLK 4
|
|
#define BREC_CHAIN_RDBLK 5
|
|
|
|
|
|
/*
|
|
* Byte swapping constants
|
|
*/
|
|
#define UNIX_MODE 1 /* non-byte swapped */
|
|
#define XINU_MODE 2 /* byte swapped */
|
|
#define NUXI_MODE 3 /* byte swapped */
|
|
#define TEST_XINU_MODE 0x000000ff
|
|
#define TEST_NUXI_MODE 0x00ff0000
|
|
|
|
|
|
/*
|
|
* Read & write buffer structure
|
|
*/
|
|
typedef struct rdbuf_t rdbuf_t;
|
|
struct rdbuf_t {
|
|
int pg_num;
|
|
int rd_blktype;
|
|
int rd_offset;
|
|
char buff[PAGE_SZ * MAX_BLOCK];
|
|
};
|
|
|
|
|
|
typedef struct wrtbuf_t wrtbuf_t;
|
|
struct wrtbuf_t {
|
|
int pg_num;
|
|
int wrt_blktype;
|
|
int wrt_offset;
|
|
int prvrec_offset;
|
|
char buff[PAGE_SZ *MAX_BLOCK];
|
|
};
|
|
|
|
|
|
/*
|
|
* Structure to define a big record, these are saved on file for
|
|
* later processing of big record chains, or as preludes to displaced
|
|
* over length records from the group chain, saved on the hold file.
|
|
*/
|
|
typedef struct rec_def_t rec_def_t;
|
|
struct rec_def_t {
|
|
int start_pg;
|
|
int idlen;
|
|
int datalen;
|
|
};
|
|
|
|
|
|
/*
|
|
* Status structure for keeping track of progress whilst converting file
|
|
* from PI/open to uniVerse dynamic format.
|
|
*/
|
|
typedef struct cnv_status_t cnv_status_t;
|
|
struct cnv_status_t {
|
|
|
|
/*
|
|
* File descriptors
|
|
*/
|
|
FILE *prm_rd_desc; /* File desc of primary sf (source) */
|
|
FILE *ovf_rd_desc; /* File desc of overflow sf (source) */
|
|
FILE *prm_wrt_desc; /* File desc of primary sf (dest) */
|
|
FILE *ovf_wrt_desc; /* File desc of overflow sf (dest) */
|
|
FILE *blkmap_desc; /* File desc of page map file */
|
|
FILE *bigrec_desc; /* File of big record start pages */
|
|
FILE *savedrec_desc; /* File desc of saved record file */
|
|
FILE *setup_desc; /* File desc of setup paragraph */
|
|
|
|
/*
|
|
* Format information
|
|
*/
|
|
int grpsz_pgs; /* Basic group size in pages */
|
|
int grpsz_bytes; /* Basic group size in bytes */
|
|
int grp_count; /* Number of groups in file */
|
|
int hdr_size; /* Size of primary header in pages */
|
|
|
|
/*
|
|
* Command line options
|
|
*/
|
|
int copying; /* In situ/copying conversion */
|
|
int retain; /* Retain originals after copy */
|
|
int dict; /* Converting dictionary */
|
|
int reply_yes; /* Assume yes reply to queries */
|
|
char *file_id; /* Name of file to convert */
|
|
char *voc_id; /* VOC name of file being converted */
|
|
|
|
/*
|
|
* Process status information
|
|
*/
|
|
int file_load; /* File load info for new header */
|
|
int curr_grp; /* Primary group being processed */
|
|
int wrt_prv_blk; /* Page number of previous write blk */
|
|
int bigrec_offset; /* Offset in bigrecord file */
|
|
int write_posn; /* block number of next write slot */
|
|
int end_pg; /* Current last page in overflow */
|
|
int free_end_pt; /* Second block of data starts here */
|
|
int freelist; /* Head of free block list */
|
|
};
|
|
|
|
/* END-CODE */
|