/****************************************************************************** * * filefix.h - main include file for file fixing subsystem * * 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......................................... * 06/23/99 24993 WSM Fix record_no type in file_errors structure. * 05/07/99 24993 WSM Changes for new style files (64-bit file project). * 01/12/99 24261 WSM Adjusted find_address() prototype. * 10/19/98 23768 WSM Added btree_file to work_file, Overflow_Count to * work_group and chain_no to file_errors. * 10/16/98 23768 WSM Added function prototypes, #defines, and fields to * UVWorkfile and UVWorkgroup. * 10/14/98 23801 SAP Change copyrights. * 09/01/98 23768 DJD Module Created. * ******************************************************************************/ #include "uv.h" #include "DBFILE.h" /* Structures */ typedef struct UVheader_information { DBDADDR32 revision; DBDADDR32 filetype; DBDADDR modulo; DBDADDR32 separation; DBDADDR32 idxoff; DBDADDR freelist; DBDADDR t30curmod; DBDADDR t30basemod; DBDADDR t30largerec; DBDADDR t30filesp; DBDADDR t30nextsplit; DBDADDR32 t30Htype; DBDADDR32 t30splitload; DBDADDR32 t30mergeload; DBDADDR32 t30selectcount; DBDADDR UVsicadata; DBDADDR PartBlock; DBDADDR32 Statread; DBDADDR32 Statreadu; DBDADDR32 Statwrite; DBDADDR32 Statwriteu; DBDADDR32 Statosrd; DBDADDR32 Statoswr; DBDADDR32 Statosfrd; DBDADDR32 Statcomp; DBDADDR32 Statwickd; DBDADDR32 Statuwait; DBDADDR32 Statruhit; DBDADDR32 Statclear; DBDADDR32 Statdelete; DBDADDR32 Statselect; DBDADDR32 Statstamp; DBDADDR32 Statreads; DBDADDR32 Statrhit; DBDADDR32 Statopen; DBDADDR32 feNLSsortcsum; char feNLSsortmap[32+1]; DBDADDR32 TLfilenum; DBDADDR32 TLpfilenum; DBDADDR32 TLfeflags; DBDADDR32 TLChkpoint; char TLwarmlsn[8+1]; DBDADDR32 feNLSmapcsum; char feNLSmapname[32+1]; DBDADDR32 feClrfiltime; DBDADDR32 Baktime; DBDADDR32 BakFlags; DBDADDR Bakcnt; DBDADDR32 Mkdbstamp; DBDADDR32 UVReadonly; DBDADDR32 idxmapcolcnt; DBDADDR32 idxmapcolmap; DBDADDR32 feUDRflags; DBDADDR32 UDRid; char IDXName[256+1]; char Schema[64+1]; char rszpath[128+1]; } UVHEADER, *PUVHEADER; typedef struct UVrecord_information { DBDADDR flink; DBDADDR blink; union DBflags flagword; unsigned char *data; DBDADDR ovlink; DBDADDR32 ovcount; unsigned char *ovdata; } UVRECORD, *PUVRECORD; /* File error structure */ typedef struct file_errors { char *text_message; /* error text message */ char *action_message; /* action text FATAL errors */ int error_type; /* type of error */ int Diag_Func; /* diag funct that found it */ int Fix_Func; /* funct number to fix error */ DBDADDR group_no; /* primary buffer number */ int record_no; /* record number within group */ DBDADDR overflow_no; /* overflow buffer number */ int chain_no; /* number of buffers associated with oversized record */ struct file_errors *nextptr; /* next file_error pointer */ struct file_errors *lastptr; /* last file_error pointer */ } FILE_ERRORS, *PFILE_ERRORS; /* file detail structure to contain information on the physical file */ typedef struct filedetails { int fdesc; /* file desc for file */ char *filename; /* name for file */ DBDADDR filesize; /* size of file */ } FILEDETAILS, *PFILEDETAILS; /* global work file structure */ typedef struct work_file { char * DBfilename; /* Database filename */ FILEDETAILS primary; /* ptr to primary file details */ FILEDETAILS over; /* ptr to overflow file details */ char * filepath; /* path to file */ DBFILE * UVfile; /* database file strcuture used for locking and is DBopen'ed */ PUVHEADER file_header; int dynamic_file; /* flag to determine if dynamic file or not */ int btree_file; /* flag to determine if btree file or not */ int new_style; /* flag to determine if new style file */ int file_64bit; /* flag to determine if 64-bit */ DBDADDR headersize; /* file header size */ DBDADDR buffersize; /* file buffer size */ DBDADDR record_count; /* record count for file */ DBDADDR total_buffers; /* number of buffers in file */ unsigned char *buffers_processed; /* array to track processed buffers */ int error_count; /* error count for file */ PFILE_ERRORS file_errors; /* ptr to file errors structure */ PFILE_ERRORS file_errors_head; /* ptr to the start of file errors structure */ } WORK_FILE, *PWORK_FILE; /* global work group structure */ typedef struct work_group { UVRECORD Record; /* pointer to record in group */ UVRECORD Oversized_Record; /* pointer to record in oversized buffer */ int Record_In_Group; /* number of record in the group */ int Chain_Count; /* number of buffers linked to record */ int Overflow_Count; /* number of buffers linked to primary group */ DBDADDR Current_Group; /* current group number */ DBDADDR Overflow_Group; /* number of group if its an overflow group */ char *Last_Buffer; /* last group buffer used */ char *Oversized_Buffer; /* current oversized buffer */ char *Current_Buffer; /* current group buffer */ DBDADDR Group_Address; /* group address from start of file */ DBDADDR Last_Group_Address; /* previous group address */ DBDADDR Record_Address; /* record address from start of file */ DBDADDR Last_Record_Address; /* previous record address */ DBDADDR Oversized_Address; /* oversized record address from start of file */ DBDADDR Last_Oversized_Address; /* previous oversized record address */ } WORK_GROUP, *PWORK_GROUP; /* fix libraries logging states */ typedef struct fix_logging { int logging; /* flag to say whether logging is on or not */ char *logfilepath; /* filepath for the log file */ int output; /* flag to say whether output is going to another path */ char *outputpath; /* alternative output path */ int logfdesc; /* file desc for the log file */ } FIX_LOGGING, *PFIX_LOGGING; /* defines */ #define DIAGS 0x00 /* run as diags flag */ #define FIX 0x01 /* run as fix flag */ #define MAX_SEPARATION 8388608 /* This is the all group flag for Next x groups */ #define ALL_GROUPS ((DBDADDR) -1) /* all groups flag */ /* static chars */ static char _DATA30[] = "/DATA.30"; static char _OVER30[] = "/OVER.30"; static char _TYPE1[] = "/.Type1"; static char _LOGFILE[] = "LOGFILE"; static char _COMPLETE[] ="Complete\n"; static char _START[] = "Start\n"; static char _LOG[] = "log."; static char _DUMP[] = "dump."; static char _GRP[] = "grp."; static char _REC[] = "rec."; static char _TYPE30[] = "/.Type30"; static char _INDEXMAP[] = "/INDEX.MAP"; /* Function prototypes */ #ifdef MSWIN int add_error(char *, char *, int, int, int); int get_error(int); int delete_error(void); int getfatalerrorinfo(char *, char *); int open_work_file(char *, char *, int); int close_work_file(void); void updinfo30shm(DBFILE *, T30INFONEW *); int lock_work_file(void); int unlock_work_file(void); void get_stats_elements(PUVHEADER, DSTATS); int get_old_elements(PUVHEADER, struct UVhdrold32 *); int get_new32_elements(PUVHEADER, struct UVhdrnew32 *); int get_new64_elements(PUVHEADER, struct UVhdrnew64 *); int load_UVFile_header(void); int unload_UVFile_header(void); void set_stats_elements(PUVHEADER, DSTATS *); int set_old_elements(PUVHEADER, struct UVhdrold32 *); int set_new32_elements(PUVHEADER, struct UVhdrnew32 *); int set_new64_elements(PUVHEADER, struct UVhdrnew64 *); int write_UVFile_header(void); int file_exists(char *); DBDADDR get_max_int(void); DBDADDR get_number_groups(DBDADDR); DBDADDR get_size(DBDADDR); DBDADDR get_alignment(DBDADDR); DBDADDR get_group_end_address(DBDADDR); DBDADDR get_group_number(DBDADDR); DBDADDR get_modulus(void); DBDADDR calculate_basemod(void); DBDADDR calculate_nextsplit(void); int address_within_buffer(DBDADDR, DBDADDR); void get_UVRecord_header(PUVRECORD, char *); int get_next_buffer(int, DBDADDR, DBDADDR *, DBDADDR *, char **, PUVRECORD, int); int get_primary_group(DBDADDR); int get_next_freechainblock(DBDADDR); int get_next_oversizedblock(DBDADDR); int get_next_group(void); int get_next_recordblock(void); int safe_seek(int, DBDADDR); int safe_read(int, char *, int); int safe_write(int, char *, int); int setup_logging(int, char *); int shutdown_logging(void); int filefix_write_log(char *); int setup_output(int, char *); int shutdown_output(void); int dump_group(void); int dump_record_block(void); void set_UVRecord_header(PUVRECORD, char *, DBDADDR); int write_group(DBDADDR, int, char *); int write_null_group(DBDADDR, int); DBDADDR find_address(DBDADDR, DBDADDR, DBDADDR, int); int diag_physical_structure(int); int diag_UVFile_header(int); int diag_number_groups(int, DBDADDR); int diag_number_primary_groups(int, DBDADDR); int diag_data(int, DBDADDR); int diag_misc(int); int diag_next_group(int); int diag_primary_group(int, DBDADDR); int diag_next_record(int); int rundiags(int *, int); int fix_all_errors(void); int fix_file_error(void); int fix_number_groups(DBDADDR); int fix_group(void); DBDADDR adjust_flink(void); void set_buffer_info(DBDADDR); int get_recid_info(unsigned char **, int *); int fix_trunc(int, DBDADDR, DBDADDR); DBDADDR calculate_blink(void); int clear_header(char *, PUVRECORD); int correct_flink(char *, PUVRECORD); int set_flink(int, DBDADDR, DBDADDR); int clear_oversized_link(void); int correct_overflow_block(void); int clear_freechain_pointer(DBDADDR); #else int add_error(); int get_error(); int delete_error(); int getfatalerrorinfo(); int open_work_file(); int close_work_file(); int lock_work_file(); int unlock_work_file(); void get_stats_elements(); int get_old_elements(); int get_new32_elements(); int get_new64_elements(); int load_UVFile_header(); int unload_UVFile_header(); void set_stats_elements(); int set_old_elements(); int set_new32_elements(); int set_new64_elements(); int write_UVFile_header(); int file_exists(); DBDADDR get_max_int(); DBDADDR get_number_groups(); DBDADDR get_size(); DBDADDR get_alignment(); DBDADDR get_group_address(); DBDADDR get_group_number(); DBDADDR get_modulus(); DBDADDR calculate_basemod(); DBDADDR calculate_nextsplit(); int address_within_buffer(); void get_UVRecord_header(); int get_next_buffer(); int get_primary_group(); int get_next_freechainblock(); int get_next_oversizedblock(); int get_next_group(); int get_next_recordblock(); int safe_seek(); int safe_read(); int safe_write(); int setup_logging(); int shutdown_logging(); int filefix_write_log(); int setup_output(); int shutdown_output(); int dump_group(); int dump_record_block(); void set_UVRecord_header(); int write_group(); int write_null_group(); DBDADDR find_address(); int diag_physical_structure(); int diag_UVFile_header(); int diag_number_groups(); int diag_number_primary_groups(); int diag_data(); int diag_misc(); int diag_next_group(); int diag_primary_group(); int diag_next_record(); int rundiags(); int fix_all_errors(); int fix_file_error(); int fix_number_groups(); int fix_group(); DBDADDR adjust_flink(); void set_buffer_info(); int get_recid_info(); int fix_trunc(); DBDADDR calculate_blink(); int clear_header(); int correct_flink(); int set_flink(); int clear_oversized_link(); int correct_overflow_block(); int clear_freechain_pointer(); #endif