#include /* main dbf file functions */ #pragma pack(1) /* system definitions */ #define AMIGADOS 0 #define IBMPCDOS 1 /* dbase constants */ #define TRUE 1 #define FALSE 0 #define block_size 32 #define end_of_field "/r" #define max_recs 1000 /* 4000 chars or 128 fields */ #define max_fields 128 #define max_numeric 19 #define max_index 5 #define max_area 25 #define date_size 8 #define fld_nam_len 11 #define header_terminator_byte 0x0D #define is_deleted 0x2A #define not_deleted 0x20 /* dbase type definitions */ typedef char update[3]; typedef char dbfile[12]; typedef char order_type[3]; typedef order_type order_array_type[max_fields] ; typedef char field_name[fld_nam_len]; typedef struct header_rec { char version ; /* 0x03 for DBIII */ update last_updated ; long num_of_recs ; short data_start ; /* offset of actual data */ short cpr ; /* chars per rec */ char reserved[20] ; } header_rec ; /* 32 bytes */ typedef struct field_rec /* 32 bytes for each field */ { char field_name[11] ; char field_type ; long field_data_address ; char field_length ; char decimal_places ; short multiuser1 ; char workid ; short multiuser2 ; char flag ; char reserved[8] ; } field_rec ; typedef struct field_rec field_array[max_fields]; typedef struct index { char idx; ENTRY *pe; IX_DESC *pix; } index; typedef struct select_rec { char a; /* area used for this file */ FILE *fp; /* file pointer */ char fok; /* file status */ header_rec *hr; /* header info */ field_rec *fr[max_fields]; /* field info */ char * fd[max_fields]; /* make a char * for each field in a rec */ short num_of_fields; long crn; /* current record number */ char *rd; /* record data buffer */ char del; /* delete status of current record */ char ord; /* current index order */ /* index fields for bplus */ index i[max_index]; } select_rec ; #pragma pack() /* Prototypes */ /* misc functions */ #ifdef AMIGADOS void swab(char *int1, char *int2, int no_bytes) ; #endif char FAR PASCAL _export wait(char ch); void FAR PASCAL _export charproc(char *field, char length, long sub) ; char * FAR PASCAL _export dateproc(int length, int sub, int sub2) ; char FAR PASCAL _export logiproc(int sub, int sub2) ; char * FAR PASCAL _export memoproc(int sub,int sub2) ; char * FAR PASCAL _export nmbrproc(int length, int sub, int sub2) ; char * FAR PASCAL _export dbname(char *tmpstr) ; char * FAR PASCAL _export dxname(char *tmpstr) ; char * FAR PASCAL _export rstr(char *tmpstr, int newlen); char * FAR PASCAL _export lstr(char *tmpstr, int newlen); void FAR PASCAL _export rtrim(char *tmpfld); int FAR PASCAL _export strnicmps(char *str1,char *str2) ; int FAR PASCAL _export memchk(char *buff,char *function,char variable[],unsigned long mem); /* file functions */ int FAR PASCAL _export initbase(); int FAR PASCAL _export read_rec(char area); int FAR PASCAL _export write_rec(char area); int FAR PASCAL _export add_rec(char area); int FAR PASCAL _export goto_rec(long recnum); int FAR PASCAL _export del_rec(char area); void FAR PASCAL _export pack(char area); int FAR PASCAL _export read_header(char area); int FAR PASCAL _export open_file(dbfile filename, char area); int FAR PASCAL _export close_file(char area); void FAR PASCAL _export read_fields(char area); int FAR PASCAL _export import(dbfile infile, dbfile outfile); void FAR PASCAL _export export(dbfile infile, dbfile outfile); void FAR PASCAL _export swabdbf(dbfile infile); int FAR PASCAL _export copyfile(char *cp[]); int FAR PASCAL _export create_dbf(dbfile outfile,field_array fields,int num_of_fields); int FAR PASCAL _export copy_stru(dbfile outfile);