home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c163 / 3.ddi / SCRE_SOU.EXE / D4DATA.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-29  |  48.4 KB  |  1,335 lines

  1. /* d4data.h   (c)Copyright Sequiter Software Inc., 1990-1992. All rights reserved. */
  2.  
  3. #ifndef S4UNIX
  4. #ifndef _SIZE_T_DEFINED_     /* Watcom */
  5. #ifndef _SIZE_T_DEFINED      /* Microsoft, Metaware */
  6. #ifndef _SIZE_T              /* Borland  */
  7.    typedef unsigned size_t ;
  8. #endif
  9. #endif
  10. #endif
  11. #endif
  12.  
  13. #ifdef S4GERMAN
  14.    #define S4LANGUAGE
  15. #endif
  16.  
  17. #ifdef S4FRENCH
  18.    #define S4LANGUAGE
  19. #endif
  20.  
  21. #ifdef __TURBOC__
  22.    #ifdef S4DLL
  23.       #define S4CLASS huge
  24.       #define S4FUNCTION far pascal
  25.    #endif
  26. #endif
  27.  
  28. #ifdef _MSC_VER
  29.    #ifdef S4DLL
  30.       #ifdef __cplusplus
  31.          #define S4CLASS
  32.       #else
  33.          #define S4CLASS huge
  34.       #endif
  35.       #define S4FUNCTION far pascal
  36.    #endif
  37. #endif
  38.  
  39. #ifdef __ZTC__
  40.    #ifdef S4DLL
  41.       #ifdef __cplusplus
  42.          #define S4CLASS
  43.       #else
  44.          #define S4CLASS huge
  45.       #endif
  46.       #define S4FUNCTION far pascal
  47.    #endif
  48. #endif
  49.  
  50. #ifdef S4DLL_BUILD
  51.    #define __DLL__
  52. #endif
  53.  
  54. #ifdef __DLL__
  55.    #define S4DLL
  56.    #define S4CLASS _export
  57.    #define S4FUNCTION far pascal _export
  58. #endif
  59.  
  60. #ifdef S4DLL
  61.    #define S4WINDOWS
  62. #endif
  63.  
  64. #ifndef S4CLASS
  65.    #define S4CLASS
  66.    #define S4FUNCTION
  67. #endif
  68.  
  69. #ifdef S4DLL
  70.    #define S4CALL far pascal _export
  71. #else
  72.    #ifdef _MSC_VER
  73.       #define S4CALL _cdecl S4FUNCTION
  74.    #else
  75.       #define S4CALL S4FUNCTION
  76.    #endif
  77. #endif
  78.  
  79. #ifdef S4WINDOWS
  80.    typedef unsigned int UINT ;
  81. #endif
  82.  
  83. #ifdef _MSC_VER
  84.    #define S4ERROR cdecl
  85. #endif
  86. #ifdef __TURBOC__
  87.    #define S4ERROR cdecl
  88. #endif
  89. #ifdef __ZTC__
  90.    #define S4ERROR cdecl
  91. #endif
  92. #ifdef __WATCOMC__
  93.    #define S4OTHER_BCD
  94.    #define S4ERROR cdecl
  95. #endif
  96. #ifndef S4ERROR
  97.    #define S4ERROR S4FUNCTION
  98. #endif
  99.  
  100. #ifdef S4DLL
  101.    #define S4PTR far
  102. #else
  103.    #define S4PTR
  104. #endif
  105.  
  106. #ifdef S4UNIX
  107.    #include "p4port.h"
  108. #endif
  109.  
  110. #ifdef S4DEMO
  111.    #define E4DEMO_MAX 200
  112. #endif
  113.  
  114. #ifdef S4NDX
  115. /* default is to use dBASE III+/Clipper memo file formats if using .NDX index file formats */
  116. #define S4MNDX
  117. #define N4OTHER
  118. #endif
  119.  
  120. #ifdef S4CLIPPER
  121. /* default is to use dBASE III+/Clipper memo file formats if using .NTX index file formats */
  122. #define S4MNDX
  123. #define N4OTHER
  124. #endif
  125.  
  126. #ifdef S4FOX
  127. /* default is to use foxpro memo file formats if using foxpro index file formats */
  128. #define S4MFOX
  129. #endif
  130.  
  131. #ifndef S4FOX
  132. #ifndef N4OTHER
  133.    #define S4MDX
  134. #endif
  135. #endif
  136.  
  137. #ifdef S4MNDX
  138. #define   M4MEMO_SIZE   0x200
  139. #endif
  140.  
  141. #ifndef S4UNIX
  142.    typedef  const void S4PTR *  S4CMP_PARM ;
  143. #endif
  144.  
  145. typedef int S4CALL  S4CMP_FUNCTION( S4CMP_PARM, S4CMP_PARM, size_t) ;
  146.  
  147. #ifdef S4DLL
  148.    #define s4assign_cmp(s4,f)  (s4)->cmp = (S4CMP_FUNCTION S4PTR *) MakeProcInstance((FARPROC) f, (s4)->code_base->hInst)
  149. #else
  150.    #define s4assign_cmp(s4,f)  (s4)->cmp = (S4CMP_FUNCTION S4PTR *) (f)
  151. #endif
  152.  
  153. /* Integer Return Codes */
  154. #define r4success  0
  155. #define r4found    1    /* Primary Key Match */
  156. #define r4after    2
  157. #define r4eof      3
  158. #define r4bof      4
  159. #define r4entry    5    /* No index file entry or no record (go) */
  160. #define r4descending   10
  161. #define r4unique   20   /* Key is not unique, do not write/append */
  162. #define r4unique_continue  25    /* Key is not unique, write/append anyway */
  163. #define r4ignore   40
  164. #define r4keep     45
  165. #define r4locked   50
  166. #define r4no_create 60   /* Could not create file */
  167. #define r4no_open  70   /* Could not open file */
  168. #define r4no_tag   80   /* d4seek, with no default tag */
  169.  
  170. /* General Disk Access Errors */
  171. #define e4close   -10
  172. #define e4create  -20 
  173. #define e4len     -30 
  174. #define e4len_set -40 
  175. #define e4lock    -50 
  176. #define e4open    -60 
  177. #define e4read    -70
  178. #define e4remove  -80
  179. #define e4rename  -90
  180. #define e4seek    -100 
  181. #define e4unlock  -110 
  182. #define e4write   -120 
  183.  
  184. /* Database Specific Errors */
  185. #define e4data  -200 
  186. #define e4field_name -210   /* Invalid field name */
  187. #define e4field_type -220
  188. #define e4record_len -230 
  189.  
  190. /* Index File Specific Errors */
  191. #define e4entry  -300  /* Tag entry not located */
  192. #define e4index  -310 
  193. #define e4tag_name  -330 
  194. #define e4unique    -340  /* Key is not unique */
  195.  
  196. /* Expression Errors */
  197. #define e4comma_expected   -400 
  198. #define e4complete   -410 
  199. #define e4data_name  -420 
  200. #define e4num_parms   -430 
  201. #define e4overflow   -440  /* Overflow while evaluating expression */
  202. #define e4right_missing   -450
  203. #define e4type_sub      -460 
  204. #define e4unrec_function   -470 
  205. #define e4unrec_operator   -480 
  206. #define e4unrec_value   -490
  207. #define e4unterminated   -500 
  208.  
  209. /* Critical Errors */
  210. #define e4info     -910  /* Unexpected information in internal variable */
  211. #define e4memory   -920  /* Out of memory */
  212. #define e4parm     -930  /* Unexpected parameter */
  213. #define e4demo     -940  /* Exceeded maximum record number for demo */
  214. #define e4result   -950  /* Unexpected result */
  215.  
  216. #define E4DEMO_MAX 200 
  217.  
  218. /* garbage between expression and filter is length */
  219. #ifdef  S4FOX
  220. #define I4MULTIPLY     1
  221. #define B4DO_BACK_LEVEL 3
  222. #define I4MAX_KEY_SIZE 240
  223. #else
  224.    #define I4MULTIPLY     512
  225.  
  226.    #ifdef S4NDX
  227.       #define I4MAX_KEY_SIZE 100
  228.    #else
  229.       #ifdef S4CLIPPER
  230.          #define I4MAX_KEY_SIZE 338
  231.       #else
  232.          #define I4MAX_KEY_SIZE 102 
  233.       #endif
  234.    #endif
  235. #endif
  236.  
  237. #define D4GARBAGE_LEN  518
  238. #define L4LOCK_POS     1000000000L 
  239. #define E4ACCURACY     1.0e-13
  240. #define E4ACCURACY_DIGITS  15
  241.  
  242. typedef void C4STOK( char S4PTR *, char S4PTR *, int ) ;
  243. typedef void C4DTOK( char S4PTR *, double ) ;
  244.  
  245. struct D4DATA_st ;
  246. struct F4MEMO_st ;
  247. struct I4INDEX_st ;
  248. struct T4TAG_st ;
  249.  
  250. typedef struct l4link_st
  251. {
  252.    struct l4link_st S4PTR *n, S4PTR *p ;
  253. } L4LINK ;
  254.  
  255. #ifdef __cplusplus
  256. typedef struct S4CLASS
  257. #else
  258. typedef struct
  259. #endif
  260. {
  261.    L4LINK S4PTR *last ;           /* The last Link */
  262.    void   S4PTR *selected ;
  263.    int     n_link ;         /* The number of links in the list */
  264. } L4LIST ;
  265.  
  266. typedef struct
  267. {
  268.    L4LINK link ;
  269.    double  data ;  /* Make sure it is on a boundry good for at least a double  */
  270. } Y4CHUNK ;
  271.  
  272. typedef struct
  273. {
  274.    L4LINK link ;
  275.  
  276.    L4LIST      chunks ;      /* Chunks of pieces */
  277.    L4LIST      pieces ;      /* A list of available memory pieces */
  278.  
  279.    int         unit_start;   /* The starting # of entries for the Memory Type */
  280.    unsigned    unit_size ;   /* The size of each allocated piece */
  281.    int         unit_expand ; /* The expansion # of entries for the Memory Type */
  282.    int         n_repeat ;    /* The number of times entry returned for 'new' */
  283.                              /* If n_repeat is '-1', it is a temporary entry. */
  284.    int         n_used ;      /* The number of entries used */
  285. }  Y4MEMORY_TYPE ;
  286.  
  287. #ifdef __cplusplus
  288. typedef struct S4CLASS
  289. #else
  290. typedef struct
  291. #endif
  292. {
  293.    unsigned hWnd ;            /* For use under Microsoft Windows */
  294.    unsigned hInst ;
  295.  
  296.    L4LIST   data_list ;     /* A list of open data files. */
  297.    int default_unique_error ; /* e4unique, r4unique, r4unique_continue */
  298.    char date_format[19]; /* Longest is September 15, 1990 */
  299.  
  300.    unsigned mem_size_block ;      /* Block size (bytes) for memo and index files */
  301.    unsigned mem_size_sort_pool ;  /* The default pool size for sorting */
  302.    unsigned mem_size_sort_buffer ;/* The default file buffer size when sorting */
  303.    unsigned mem_size_buffer ;     /* Pack, Zap */
  304.  
  305.    int mem_expand_block ;  /* Expanding block memory allocation */
  306.    int mem_expand_data ;   /* Expanding data file allocation */
  307.    int mem_expand_index ;  /* Expanding index file allocation */
  308.    int mem_expand_tag ;    /* Expanding index file allocation */
  309.  
  310.    int mem_start_data ;    /* Initial data file allocation */
  311.    int mem_start_block ;   /* Initial block memory allocation for index files */
  312.    int mem_start_index ;   /* Initial index file allocation */
  313.    int mem_start_tag ;     /* Initial index file allocation */
  314.  
  315.    /* True/False Flags */
  316.    int  field_name_error ;    
  317.    int  go_error ;             /* Do 'Data::go' error ? */
  318.    int  open_error ;           /* Do 'File::open' error ? */
  319.    int  create_error ;         /* Do 'File::create' error ? */
  320.    int  read_lock ;            /* Do lock when reading database ? */
  321.    int  skip_error ;           /* Do 'DataIndex::skip' error ? */
  322.    int  tag_name_error ;     
  323.    int  safety ;               /* File create with safety ? */
  324.    int  wait   ;               /* Wait when locking ? */
  325.    int  auto_open ;            /* Automatic production index file opening */
  326.  
  327.    Y4MEMORY_TYPE S4PTR *index_memory ;
  328.    Y4MEMORY_TYPE S4PTR *data_memory ;
  329.    Y4MEMORY_TYPE S4PTR *tag_memory ;
  330.  
  331.    #ifdef S4CLIPPER
  332.       int numeric_str_len ;    /* the default length for clipper index files */
  333.       int decimals ;           /* the default # decimals for clipper index files */
  334.    #endif
  335.  
  336.    int  error_code ;          
  337.    int  debug_int ;            /* used to check structure integrity (set to 0x5281) */
  338. } C4CODE ;
  339.  
  340. typedef struct
  341. {
  342.    char S4PTR *name ;
  343.    C4CODE S4PTR *code_base ;
  344.    int   hand ;
  345.    char  is_temp ;      /* True if it is a temporary file */
  346.    char  do_alloc_free ;
  347. } H4FILE ;
  348.  
  349. typedef struct
  350. {
  351.    H4FILE     file ;
  352.    short      block_size ;               /* Bytes */
  353.    struct D4DATA_st  S4PTR *data ;
  354. } M4FILE ;
  355.  
  356. typedef struct
  357. {
  358.    H4FILE S4PTR *file ;
  359.  
  360.    long  pos ;          /* The next position to read from */
  361.    char S4PTR *buffer ;
  362.    unsigned next_read_len ;
  363.    unsigned total ;     /* Total buffer length */
  364.    unsigned working ;   /* Temporary working buffer length (to help align write) */
  365.    unsigned avail ;     /* # of bytes currently available */
  366. } H4SEQ_READ ;
  367.  
  368. typedef struct
  369. {
  370.    H4FILE S4PTR *file ;
  371.  
  372.    long  pos ;          /* The next position to read from */
  373.    char S4PTR *buffer ;
  374.    unsigned total ;     /* Total buffer length */
  375.    unsigned working ;   /* Temporary working buffer length (to help align write) */
  376.    unsigned avail ;     /* # of bytes left in working buffer */
  377. } H4SEQ_WRITE ;
  378.  
  379. typedef struct  /* Data File Format */
  380. {
  381.    char     name[11] ;
  382.    char     type ;
  383.    char     filler[4] ;
  384.    unsigned char  len ;
  385.    unsigned char  dec ;
  386.    char     filler2[13] ;
  387.    char    has_tag ;
  388. } F4FIELD_IMAGE ;
  389.  
  390. typedef struct  /* Internal Structure and Field Routines. */
  391. {
  392.    char        name[11] ;
  393.    unsigned    len ;
  394.    int         dec ;
  395.    int         type ;
  396.    int         offset ;
  397.    struct D4DATA_st  S4PTR *data ;
  398.    struct F4MEMO_st  S4PTR *memo ;
  399.    #ifdef S4VBASIC
  400.       int  debug_int ;         /* used to check structure integrity (set to 0x5281) */
  401.    #endif
  402. } F4FIELD ;
  403.  
  404. typedef struct F4MEMO_st
  405. {
  406.    int    is_changed ;
  407.  
  408.    int    status ;           /* 0 - Current contents, 1 - Unknown */
  409.    char  S4PTR *contents ;
  410.    unsigned  len ;
  411.    unsigned  len_max ;
  412.    F4FIELD  S4PTR *field ;
  413. } F4MEMO ;
  414.  
  415. typedef struct  /* Creating Data File */
  416. {
  417.    char   S4PTR *name ;
  418.    char    type ;
  419.    short   len ;
  420.    short   dec ;
  421. } F4FIELD_INFO ;
  422.  
  423. typedef struct
  424. {
  425.    /* Database Header Information */
  426.    char     version ;        /* 83H with .dbt, 03H without */
  427.    char     yy ;             /* Last Update */
  428.    char     mm ;
  429.    char     dd ;
  430.    long     num_recs ;
  431.    unsigned short header_len; /* Header Length, Indicates start of data */
  432.    unsigned short record_len;
  433.    char     zero[16] ;
  434.    short    has_mdx ;    /* 1 for true */
  435.    char     zero2[2] ;
  436. } D4DATA_HEADER_FULL ;
  437.  
  438. typedef struct D4DATA_st
  439. {
  440.    L4LINK  link ;
  441.  
  442.    /* Database Header Information */
  443.    char     version ;        /* 83H with .dbt, 03H without */
  444.    char     yy ;             /* Last Update */
  445.    char     mm ;
  446.    char     dd ;
  447.    long     num_recs ;
  448.    unsigned short header_len; /* Header Length, Indicates start of data */
  449.  
  450.    char     S4PTR *record_old ;          /* Data allocated with 'u4alloc' */
  451.    char     S4PTR *record ;              /* Data allocated with 'u4alloc' */
  452.                                  /* Extra byte added for temporary CTRL_Z */
  453.    unsigned record_width ;
  454.    int      record_changed ;      /* T/F */
  455.    long     rec_num ;             /* Record number; -1 unknown; 0 for append */
  456.    long     rec_num_old ;         /* Record number, -1 none present; 0 for append */
  457.  
  458.    H4FILE   file ;
  459.    char     alias[11] ;
  460.  
  461.    char     memo_validated ; /* Can we be sure memo id #'s are up to date. */
  462.  
  463.    C4CODE   S4PTR *code_base ;
  464.    short    has_mdx ;        /* Has an MDX file attached to it */
  465.  
  466.    F4FIELD  S4PTR *fields ;        /* An array of field pointers */
  467.    int      n_fields ;       /* The number of data fields in the database */
  468.  
  469.    F4MEMO   S4PTR *fields_memo ;    /* A list of fields to be flushed */
  470.    int      n_fields_memo ;  /* The number of memo files in the database */
  471.  
  472.    long     locked_record ;  /* 'locks' data when 'n_locks <= 1' */
  473.    long     S4PTR *locks ;
  474.    int      n_locks ;        /* Number of elements in 'locks' allocated */
  475.    int      num_locked ;     /* Number of records locked */
  476.    int      file_lock ;      /* True if entire file is locked */
  477.    int      append_lock ;    /* True if the file is locked for appending */
  478.  
  479.    int      file_changed ;   /* True if the file has been changed since */
  480.                                 /* the header has been updated. */
  481.  
  482.    L4LIST   indexes ;
  483.    int      bof_flag, eof_flag ;    /* Beginning/End of File flags */
  484.  
  485.    short    block_size ;
  486.    M4FILE   memo_file ;      /* Memo file handle */
  487.    #ifdef S4VBASIC
  488.       int  debug_int ;      /* used to check structure integrity (set to 0x5281) */
  489.    #endif
  490. } D4DATA ;
  491.  
  492. typedef struct e4expr_st
  493. {
  494.    char    S4PTR *source ;       /* The character version of the expression */
  495.    D4DATA  S4PTR *data ;         /* The selected database when originally parsed */
  496.    char    S4PTR *parsed ;       /* The parsed version of the expression */
  497.    int     type ;
  498.    #ifdef S4CLIPPER
  499.       int   key_len ;         /* used for CLIPPER version */
  500.       int   num_decimals ;         /* used for CLIPPER version */
  501.    #endif
  502. } E4EXPR ;
  503.  
  504. #ifdef N4OTHER
  505.    typedef struct
  506.    {
  507.       long  pointer ;    /* =0L if record, not pointer */
  508.       long  num ;
  509.       char  value[1] ;  /* The key size is variable */
  510.    } B4KEY_DATA ;
  511.    
  512.    #define I4MAX_EXPR_SIZE 256
  513.    #ifdef S4NDX
  514.       #define B4BLOCK_SIZE 512
  515.    #else
  516.       #ifdef S4CLIPPER
  517.          #define B4BLOCK_SIZE 1024
  518.       #endif
  519.    #endif
  520. #else
  521.    typedef struct
  522.    {
  523.       long  num ;
  524.       char  value[1] ;  /* The key size is variable */
  525.    } B4KEY_DATA ;
  526. #endif
  527.  
  528. #ifdef S4FOX
  529. #define VERSION_POS 498L
  530.  
  531. typedef struct
  532. {
  533.    int trail1 ;
  534.    int trail2 ;
  535.    int dup1 ;
  536.    int dup2 ;
  537. } INSERT_STRUCT ;
  538.  
  539. /* the following structure is used only on the leaf nodes of the tree structure */
  540. typedef struct
  541. {
  542.    short            free_space ;        /* # bytes available in node */
  543.    unsigned long    rec_num_mask ;      /* record number mask */
  544.    unsigned char    dup_byte_cnt ;      /* duplicate byte mask count */
  545.    unsigned char    trail_byte_cnt ;    /* Trailing byte mask count */
  546.    unsigned char    rec_num_len ;       /* # bits used for record number */
  547.    unsigned char    dup_cnt_len ;       /* # bits used for duplicate count */
  548.    unsigned char    trail_cnt_len ;     /* # bits used for trail count */
  549.    unsigned char    info_len ;          /* # bytes for holding record number, */
  550. } B4NODE_HEADER ;
  551.  
  552. typedef struct
  553. {
  554.       short      node_attribute ;    /* 0=index, 1=root, 2=leaf */
  555.       short      n_keys ;            /* Block Image starts here */
  556.       long       left_node ;         /* -1 if not present */
  557.       long       right_node ;        /* -1 if not present */
  558. } B4STD_HEADER ;
  559.  
  560. typedef struct
  561. {
  562.    L4LINK link ;
  563.    struct T4TAG_st  *tag ;
  564.  
  565.    int   changed ;
  566.    long  file_block ;     /* Identifies block within index file */
  567.    int   key_on ;         /* The current key within the block */
  568.    int   built_on ;       /* the 'current' key value (i.e. key really 'on') */
  569.    int   cur_trail_cnt ;  /* current value used for seeking */
  570.    int   cur_dup_cnt ;    /* current value used for seeking */
  571.    int   dup_pos ;        /* bit offset into the info for the duplicate data */
  572.    int   trail_pos ;      /* bit offset into the info for the trail data */
  573.    int   rec_pos ;        /* bit offset into the info for the record # data */
  574.    char  *cur_pos ;       /* current position into the data (starts at end) */
  575.    B4KEY_DATA *current ;
  576.    B4KEY_DATA *saved ;
  577.  
  578.    B4STD_HEADER header ;
  579.    B4NODE_HEADER node_hdr ;    /* only if the block is a leaf */
  580.    char  data[1] ;        /* the remaining data */
  581. } B4BLOCK ;
  582.  
  583. /* next is the # of bytes of important info for T4HEADER */
  584. #define T4HEADER_WR_LEN 0x10
  585. /* block_size is 512 for foxpro */
  586. #define B4BLOCK_SIZE 512
  587. #endif  /* ifdef S4FOX  */
  588.  
  589. #ifndef S4FOX
  590.  
  591. #ifdef S4NDX
  592.    typedef struct
  593.    {
  594.       long     root ;
  595.       long     eof ;
  596.       char     n1_dummy ;
  597.       char     db_type ;
  598.       char     n2_dummy[2] ;
  599.       short    key_len  ;
  600.       short    keys_max ;           /* Maximum # of keys per block;  <= 100 */
  601.       short    int_or_date ;        /* TRUE (1) if Numeric or Date Key */
  602.       short    group_len ;          /* key_len plus 8 increased to a multiple of 2 */
  603.       short    dummy ;
  604.       short    unique ;             /* TRUE if Unique */
  605.  
  606.  /*   char     expression[256] ; */
  607.  /*   long     version ; */
  608.    } I4IND_HEAD_WRITE;
  609. #else
  610.    #ifdef S4CLIPPER
  611.       typedef struct
  612.       {
  613.          short          sign ;
  614.          short          version ;
  615.          long           root ;          /* Root Block */
  616.          long           eof ;           /* First Free Block Pointer */
  617.          short          group_len ;     /* Key Length + 2*sizeof(long) */
  618.          short          key_len ;       /* Key Length */
  619.          short          key_dec ;       /* Number of Decimals in Key */
  620.          short          keys_max ;      /* Maximum # of keys per block;  <= 100 */
  621.          short          keys_half ;     /* Maximum # of keys per half block */
  622.  
  623.     /*   char           expression[256];   The index expression corresponding to the database. */ 
  624.     /*   short          unique   ;         TRUE if Unique */ 
  625.       } I4IND_HEAD_WRITE;
  626.    #endif
  627. #endif
  628.  
  629. #ifdef S4NDX
  630. typedef struct
  631. {
  632.    long     old_version ;
  633.    int      header_offset ;
  634.    char     type ;
  635.  
  636.    long     root ;
  637.    long     eof ;
  638.    char     n1_dummy ;
  639.    char     db_type ;
  640.    char     n2_dummy[2] ;
  641.    short    key_len  ;
  642.    short    keys_max ;           /* Maximum # of keys per block;  <= 100 */
  643.    short    int_or_date ;        /* TRUE (1) if Numeric or Date Key */
  644.    short    group_len ;          /* key_len plus 8 increased to a multiple of 2 */
  645.    short    dummy ;
  646.    short    unique ;             /* TRUE if Unique */
  647. /* char     expression[256] ; */
  648.    long     version ;
  649. }  T4HEADER ;
  650. #else
  651.    #ifdef S4CLIPPER
  652.       typedef struct
  653.       {
  654.          long       old_version ;
  655.          int        header_offset ;
  656.          char       type ;
  657.          long       virtual_eof ;   /* The next available file block */
  658.          short      sign ;
  659.          short      version ;
  660.          long       root ;          /* Root Block */
  661.          long       eof ;           /* First Free Block Pointer */
  662.          short      group_len ;     /* Key Length + 2*sizeof(long) */
  663.          short      key_len ;       /* Key Length */
  664.          short      key_dec ;       /* Number of Decimals in Key */
  665.          short      keys_max ;      /* Maximum # of keys per block;  <= 100 */
  666.          short      keys_half ;     /* Maximum # of keys per half block */
  667.       /* char       expression[256];   The index expression corresponding to the database. */ 
  668.          short      unique   ;      /* TRUE if Unique */
  669.       }  T4HEADER ;
  670.    #else
  671.       typedef struct
  672.       {
  673.          char   two ;                /* Version number (currently 2) */
  674.          char   yymmdd[3] ;          /* Date of last reindex */
  675.          char   data_name[12] ;      /* Name of associated data file */
  676.          char   dummy1[4] ;          /* extra 4 bytes for data-names-not used in DOS */
  677.          short  block_chunks ;       /* Block Size 1 to 32 (512 byte chunks) */
  678.          short  block_rw ;           /* Block Read/Write Size in bytes */
  679.          char   is_production ;      /* 1 if production index, else 0 */
  680.          char   num_slots ;          /* number possible tags (48) */
  681.          short  slot_size ;          /* number bytes/tag slot (32) */
  682.          long   num_tags ;
  683.          long   eof ;
  684.          long   free_list ;          /* start of the free list */
  685.          char   zero[4] ;
  686.          char   create_date[3];      /* not used by CodeBase++ */
  687.          char   blank ;
  688.          long   version ;
  689.       }  I4HEADER ;
  690.    #endif     /*   ifdef S4CLIPPER  */
  691. #endif     /*   ifdef S4NDX   */
  692. #endif     /*   ifndef S4FOX  */
  693.  
  694.  
  695. #ifndef S4FOX
  696. typedef struct
  697. {
  698.    L4LINK link ;
  699.    struct T4TAG_st  S4PTR *tag ;
  700.  
  701.    long  file_block ;  /* Identifies block within index file */
  702.    int   changed ;
  703.    int   key_on ;      /* The current key within the block */
  704.  
  705.    short      n_keys ; /* Block Image starts here */
  706.    #ifdef S4NDX
  707.       char       dummy[2] ;
  708.       B4KEY_DATA data ;
  709.    #else
  710.       #ifdef S4CLIPPER
  711.          short pointers[511] ;
  712.          B4KEY_DATA *data ;
  713.       #else
  714.          char       dummy[6] ;
  715.          B4KEY_DATA info ;
  716.       #endif
  717.    #endif
  718. } B4BLOCK ;
  719.  
  720. typedef struct
  721. {
  722.    long  header_pos ;          /* Header position (in 512 byte chunks) */
  723.    char  tag[10] ;
  724.    short x1000 ;               /* used for dBASE/SQL expression type - dBASE only allowed for CBPP 1.0x */
  725.    char  left_chld ;
  726.    char  right_chld ;
  727.    char  parent ;
  728.    char  x2 ;
  729.    char  index_type ;
  730.    char  zeros[11] ;
  731. } T4DESC ;
  732. #endif     /* ifndef  S4FOX  */
  733.  
  734. #ifndef N4OTHER
  735. typedef struct
  736. {
  737. #ifdef S4FOX
  738.    long           root ;            /* -1 means unknown */
  739.    long           free_list ;       /* start of the free list (-1 if none) */
  740.    char           dummy1[4] ;       /* Key Length */
  741.    short          key_len ;         /* 0x01 Uniq; 0x08 For Clause; 0x32 Compact; 0x80 Compound */
  742.    unsigned char  type_code;        /* unused */
  743.    unsigned char  signature ;     
  744.                                     
  745. /* char           dummy2[482] ;        unused */
  746.    long           version ;         /* CodeBase uses for version # */
  747.    short          descending   ;    /* 1 = descending, 0 = ascending */
  748.    short          filter_pos ;      /* not used, == to expr_len */
  749.    short          filter_len ;      /* length of filter clause */
  750.    short          expr_pos ;        /* not used, == to 0  */
  751.    short          expr_len ;        /* length of expression */
  752. /* char           expr_pool[512] ;  expression and filter pool */
  753. #else
  754.    long           root ;            /* -1 means unknown */
  755.    char           dummy1[4] ;
  756.    char           type_code;        /* 0x10 Normal; 0x58 Uniq,Desc; 0x50 Uniq; 0x18 Desc */
  757.    char           type ;            /* N,D, or C (F is type N)  */
  758.    char           dummy2[2] ;
  759.    short          value_len ;
  760.    short          keys_max ;        /* Maximum # of keys per block;  <= 100  */
  761.    char           dummy3[2] ;       /* 1 if Numeric or Date Key (NDX only) */
  762.    short          group_len ;       /* value_len plus 4 (MDX); plus 8 (NDX) */
  763.    char           version ;
  764.    char           dummy4 ;
  765.    short          unique   ;        /* 0x4000 (TRUE)if Unique */
  766.  
  767.    /* Note, 'expr_key[220]' comes after 'unique' and */
  768.    /*       'expr_filter[220]' comes at position 0x2FA */
  769. #endif
  770. }  T4HEADER ;
  771. #endif   /*  ifndef N4OTHER  */
  772.  
  773. typedef struct T4TAG_st
  774. {
  775.    L4LINK link ;
  776.  
  777.    E4EXPR   S4PTR  *expr ;
  778.    E4EXPR   S4PTR  *filter ;
  779.    int              unique_error; /* Is rewriting a unique key an error ? */
  780.    struct I4INDEX_st S4PTR *index ;
  781.    S4CMP_FUNCTION  *cmp ;
  782.    C4STOK S4PTR    *stok ;               /* Conversion for 'seek' */
  783.    C4DTOK S4PTR    *dtok ;               /* Conversion for 'seek' */
  784.    C4CODE S4PTR    *code_base ;
  785.    char             alias[11] ;
  786.    char             has_keys ;
  787.    L4LIST           blocks ;
  788.  
  789.    #ifdef S4FOX
  790.       char          p_char ;
  791.    #endif
  792.  
  793.    #ifdef N4OTHER
  794.       H4FILE        file ;
  795.       int           file_locked ;
  796.    #endif
  797.  
  798.    T4HEADER    header ;
  799.    long        header_offset ;     /* Offset in file to the tag's header info. */
  800.    int         root_write ;        /* True if 'header.root' needs to be written */
  801.    long        lock_pos ;          /* The file offset to physically lock */
  802.    int         key_dec ;
  803.    L4LIST      saved ;
  804.    int         debug_int ;         /* used to check structure integrity (set to 0x5281) */
  805. } T4TAG ;
  806.  
  807. typedef struct
  808. {
  809.    char S4PTR *name ;
  810.    char S4PTR *expression ;
  811.    char S4PTR *filter ;
  812.    int   unique ;
  813.    int   descending ;
  814. } T4TAG_INFO ;
  815.  
  816. typedef struct I4INDEX_st
  817. {
  818.    L4LINK  link ;
  819.  
  820.    H4FILE  file ;
  821.    D4DATA S4PTR *data ;
  822.    C4CODE S4PTR *code_base ;
  823.    L4LIST  tags ;
  824.  
  825.    #ifdef S4FOX
  826.       T4TAG *tag_index ;    /* the tags are a tag in the index file! */
  827.       long  eof ;
  828.    #else
  829.       #ifdef N4OTHER
  830.          char alias[11] ;
  831.         char *path ;
  832.       #else
  833.          I4HEADER header ;
  834.       #endif
  835.    #endif
  836.  
  837.    Y4MEMORY_TYPE S4PTR *block_memory ;
  838.    T4TAG  S4PTR *tag_locked ;     /* The locked tag.  Null if none. */
  839.    int   file_locked ;    /* True if locked */
  840.    long  version_old ;
  841. } I4INDEX ;
  842.  
  843.  
  844. /* Memo File Structures */
  845.  
  846. typedef struct
  847. {
  848.    #ifdef S4MFOX
  849.       long  next_block ;  /* Memo Entry 1,2, ... */
  850.       char  usused[2] ;
  851.       short block_size ;  /* Bytes */
  852.    #else
  853.       #ifdef S4MNDX
  854.          long  next_block ;  /* Memo Entry 1,2, ... */
  855.       #else
  856.          long  next_block ;  /* Memo Entry 1,2, ... */
  857.          long  zero ;
  858.          char  file_name[8] ;
  859.          short zero2 ;
  860.          short x102 ;
  861.          short block_size ;  /* Bytes */
  862.          short zero3 ;
  863.       #endif
  864.    #endif
  865. } M4MEMO_HEADER ;
  866.  
  867. #ifndef S4MNDX
  868. #ifndef S4MFOX
  869. typedef struct
  870. {
  871.    long  next ;       /* The next free block area */
  872.    long  num ;        /* The number of free blocks in the free block area */
  873.    int   to_disk ;    /* TRUE if this information needs to be written to disk */
  874.    long  block_no ;   /* The current block number */
  875. } M4CHAIN_ENTRY ;
  876. #endif /*  ifndef S4MFOX  */
  877.  
  878. typedef struct
  879. {
  880.    #ifdef S4MFOX
  881.       long  type ;         /* 0 for picture, 1 for text -- picture not supported */
  882.       long  num_chars ;    /* Including the 'MemoBlock' */
  883.    #else
  884.       short minus_one ;    /* '-1' for dBASE IV */
  885.       short start_pos ;
  886.       long  num_chars ;    /* Including the 'MemoBlock' */
  887.    #endif
  888. } M4MEMO_BLOCK ;
  889. #endif  /*  ifndef S4MNDX  */
  890.  
  891. typedef struct
  892. {
  893.    unsigned  char  sig_dig ;  /* The number of significant digits; 52 is zero */
  894.    unsigned  char  digit_info ; /* contains one, len and sign */
  895.    unsigned  char  bcd[10] ;
  896. }  C4BCD ;
  897.  
  898. extern char   v4buffer[257] ;
  899.  
  900. #ifdef __cplusplus
  901.    extern "C" {
  902. #endif
  903.  
  904. void   S4FUNCTION a4assign( char S4PTR *, long ) ;
  905. long   S4FUNCTION a4long( char S4PTR * ) ;  /* Date Arithmetic */
  906. char S4PTR * S4FUNCTION a4cdow( char S4PTR * ) ;
  907. char S4PTR * S4FUNCTION a4cmonth( char S4PTR * ) ;
  908. int    S4FUNCTION a4day( char S4PTR * ) ;
  909. int    S4FUNCTION a4dow( char S4PTR * ) ;
  910. void   S4FUNCTION a4format( char S4PTR *, char S4PTR *, char S4PTR * ) ;/* 'dt' may be 'result'*/
  911. int    S4FUNCTION a4format_mdx2( char S4PTR *, double S4PTR * ) ;
  912. double S4FUNCTION a4format_mdx( char S4PTR *) ;
  913. void   S4FUNCTION a4init( char S4PTR *, char S4PTR *, char S4PTR * ) ;
  914. int    S4FUNCTION a4month( char S4PTR * ) ;
  915. void   S4FUNCTION a4today( char S4PTR * ) ;
  916. int    S4FUNCTION a4year( char S4PTR * ) ;
  917. void   S4FUNCTION a4time_now( char S4PTR * ) ;
  918.  
  919. #ifdef S4FOX
  920. int    S4FUNCTION b4back_skip( B4BLOCK S4PTR *, int ) ;
  921. int    S4FUNCTION b4branch_skip( B4BLOCK S4PTR *, long ) ;
  922. int    S4FUNCTION b4calc_blanks( char S4PTR *, int, char ) ;
  923. int    S4FUNCTION b4calc_dups( char S4PTR *, char S4PTR *, int ) ;
  924. int    S4FUNCTION b4bytes_reqd( B4BLOCK S4PTR *, INSERT_STRUCT S4PTR *, char S4PTR *, int ) ;
  925. int    S4FUNCTION b4do_skip( B4BLOCK S4PTR *, int ) ;
  926. int    S4FUNCTION b4go( B4BLOCK S4PTR *, int ) ;
  927. int    S4FUNCTION b4insert_leaf( B4BLOCK S4PTR *, void S4PTR *, long ) ;
  928. int    S4FUNCTION b4insert_branch( B4BLOCK S4PTR *, void S4PTR *, long, long, char ) ;
  929. void   S4FUNCTION b4leaf_init( B4BLOCK * ) ;
  930. int    S4FUNCTION b4cmp( B4BLOCK *, char *, char *, size_t, int, int ) ;
  931. int    S4FUNCTION b4leaf_seek( B4BLOCK S4PTR *, char S4PTR *, int ) ;
  932. int    S4FUNCTION b4rec_len( long ) ;
  933. int    S4FUNCTION b4reindex( B4BLOCK S4PTR * ) ;
  934. void   S4FUNCTION b4remove_leaf( B4BLOCK S4PTR * ) ;
  935. void   S4FUNCTION b4remove_branch( B4BLOCK S4PTR * ) ;
  936. void   S4FUNCTION b4br_replace( B4BLOCK S4PTR *, char S4PTR *, long ) ;
  937. int    S4FUNCTION b4top( B4BLOCK S4PTR * ) ;
  938. int    S4CALL     t4desc_memcmp( S4CMP_PARM, S4CMP_PARM, size_t ) ;
  939. void   S4FUNCTION t4branch_split( T4TAG S4PTR *, B4BLOCK S4PTR *, B4BLOCK S4PTR * ) ;
  940. void   S4FUNCTION t4leaf_split( T4TAG S4PTR *, B4BLOCK S4PTR *, B4BLOCK S4PTR * ) ;
  941. int    S4FUNCTION t4r_seek( T4TAG S4PTR *, void S4PTR *, int, long ) ;
  942. int    S4FUNCTION t4rl_bottom( T4TAG * ) ;
  943. int    S4FUNCTION t4rl_top( T4TAG * ) ;
  944. int    S4FUNCTION b4r_brseek( B4BLOCK S4PTR *, char S4PTR *, int, long ) ;
  945. long   S4FUNCTION x4recno( B4BLOCK S4PTR *, int ) ;
  946. int    S4FUNCTION x4dup_cnt( B4BLOCK S4PTR *, int ) ;
  947. int    S4FUNCTION x4trail_cnt( B4BLOCK S4PTR *, int ) ;
  948. void   S4FUNCTION x4put_info( B4NODE_HEADER S4PTR *, void S4PTR *, long, int, int ) ;
  949. int    S4FUNCTION b4insert( B4BLOCK S4PTR *, void S4PTR *, long, long, char ) ;
  950. int    S4FUNCTION b4skip( B4BLOCK S4PTR *, long, int ) ;
  951. int    S4FUNCTION t4init( T4TAG S4PTR *, I4INDEX S4PTR *, long, long, char S4PTR *) ;
  952. #else
  953.    #ifdef N4OTHER
  954.       void   S4FUNCTION b4append( B4BLOCK S4PTR *, long ) ;
  955.       int    S4FUNCTION b4skip( B4BLOCK S4PTR *, long ) ;
  956.       void   S4FUNCTION b4insert( B4BLOCK S4PTR *, void S4PTR *, long, long ) ;
  957.       #ifdef S4NDX
  958.          int    S4FUNCTION b4find( B4BLOCK S4PTR *, long, B4BLOCK S4PTR * ) ;
  959.          int    S4FUNCTION b4get_last_key( B4BLOCK S4PTR *, char S4PTR * ) ;
  960.          int    S4FUNCTION i4get_last_key( T4TAG S4PTR *,char S4PTR *, long ) ;
  961.       #else
  962.          #ifdef S4CLIPPER
  963.          int    S4FUNCTION c4clip( char S4PTR *, int ) ;
  964.          void   S4FUNCTION b4append2( B4BLOCK S4PTR *, void S4PTR *, long, long ) ;
  965.          void   S4FUNCTION t4remove_ref( T4TAG S4PTR * ) ;
  966.          int    S4FUNCTION t4get_replace_entry( T4TAG S4PTR *, B4KEY_DATA S4PTR *, B4BLOCK S4PTR * ) ;
  967.          int    S4FUNCTION t4shrink( T4TAG S4PTR *, long ) ;
  968.          #endif
  969.       #endif
  970.       int    S4FUNCTION b4room( B4BLOCK S4PTR * ) ;
  971.       int    S4FUNCTION t4close( T4TAG S4PTR * ) ;
  972.       long   S4FUNCTION t4extend( T4TAG S4PTR * ) ;
  973.       T4TAG  S4PTR *S4FUNCTION t4open( D4DATA S4PTR *, I4INDEX S4PTR *, char S4PTR * ) ;
  974.       int    S4FUNCTION t4update_header( T4TAG S4PTR * ) ;
  975.       int    S4FUNCTION t4version_check( T4TAG S4PTR* ) ;
  976.       T4TAG  S4PTR *S4FUNCTION t4create( D4DATA S4PTR *, T4TAG_INFO S4PTR *, I4INDEX S4PTR * ) ;
  977.       int    S4FUNCTION t4reindex( T4TAG S4PTR * ) ;
  978.    #else
  979.       void   S4FUNCTION b4insert( B4BLOCK S4PTR *, void S4PTR *, long ) ;
  980.       int    S4FUNCTION b4skip( B4BLOCK S4PTR *, long ) ;
  981.       int    S4FUNCTION t4init( T4TAG S4PTR *, I4INDEX S4PTR *, T4DESC S4PTR *, long ) ;
  982.    #endif
  983. #endif
  984.  
  985. #ifdef S4NDX
  986. int S4FUNCTION b4find( B4BLOCK S4PTR *, long, B4BLOCK S4PTR * ) ;
  987. int S4FUNCTION b4get_last_key( B4BLOCK S4PTR *, char S4PTR * ) ;
  988. int S4FUNCTION i4get_last_key( T4TAG S4PTR *, char S4PTR *, long ) ;
  989. #endif
  990.  
  991. B4BLOCK S4PTR *S4FUNCTION b4alloc( T4TAG S4PTR *, long ) ;
  992. int    S4FUNCTION b4flush( B4BLOCK S4PTR * ) ;
  993. void   S4FUNCTION b4free( B4BLOCK S4PTR * ) ;
  994. void   S4FUNCTION b4go_eof( B4BLOCK S4PTR * ) ;
  995. B4KEY_DATA S4PTR * S4FUNCTION b4key( B4BLOCK S4PTR *, int ) ;
  996. unsigned char S4PTR * S4FUNCTION b4key_key( B4BLOCK S4PTR *, int ) ;
  997. int    S4FUNCTION b4lastpos( B4BLOCK S4PTR * ) ;
  998. int    S4FUNCTION b4leaf( B4BLOCK S4PTR * ) ;
  999. long   S4FUNCTION b4recno( B4BLOCK S4PTR * ) ;
  1000. void   S4FUNCTION b4remove( B4BLOCK S4PTR *);
  1001. int    S4FUNCTION b4seek( B4BLOCK S4PTR *, char S4PTR *, int ) ;
  1002.  
  1003. int    S4FUNCTION c4atod2( char S4PTR *, int, double S4PTR * ) ;
  1004. double S4FUNCTION c4atod( char S4PTR *, int) ;
  1005. int    S4FUNCTION c4atoi( char S4PTR *, int) ;
  1006. long   S4FUNCTION c4atol( char S4PTR *, int) ;
  1007.  
  1008. #ifdef S4UNIX
  1009.  
  1010.    #ifdef S4MDX
  1011.       void c4bcd_from_d( char S4PTR *, double ) ;
  1012.       void c4bcd_from_a( char S4PTR *, char S4PTR *, int ) ;
  1013.       void t4str_to_date_mdx( char S4PTR *, char S4PTR *, int ) ;
  1014.       void t4no_change_str( char S4PTR *, char S4PTR *, int ) ;
  1015.       void t4no_change_double( char S4PTR *, double ) ;
  1016.    #endif
  1017.  
  1018.    #ifdef S4FOX
  1019.       void t4dbl_to_fox( char S4PTR *, double ) ;
  1020.       void t4dtstr_to_fox( char S4PTR *, char S4PTR *, int ) ;
  1021.       void t4str_to_fox( char S4PTR *, char S4PTR *, int ) ;
  1022.       void t4no_change_str( char S4PTR *, char S4PTR *, int ) ;
  1023.    #endif
  1024.  
  1025.    #ifdef S4CLIPPER
  1026.       void t4str_to_doub( char S4PTR *, char S4PTR *, int ) ;
  1027.       void t4date_doub_to_str( char S4PTR *, double ) ;
  1028.       void t4no_change_str( char S4PTR *, char S4PTR *, int ) ;
  1029.    #endif
  1030.  
  1031.    #ifdef S4NDX
  1032.       void t4str_to_doub( char S4PTR *, char S4PTR *, int ) ;
  1033.       void t4no_change_double( char S4PTR *, double ) ;
  1034.       void t4str_to_date_mdx( char S4PTR *, char S4PTR *, int ) ;
  1035.       void t4no_change_str( char S4PTR *, char S4PTR *, int ) ;
  1036.    #endif
  1037.  
  1038. #else
  1039.    #ifdef S4FOX
  1040.       C4STOK t4dtstr_to_fox ;
  1041.       C4STOK t4str_to_fox ;
  1042.       C4DTOK t4dbl_to_fox ;
  1043.    #else
  1044.       C4STOK c4bcd_from_a ;
  1045.       C4DTOK c4bcd_from_d ;
  1046.    #endif
  1047. #endif
  1048.  
  1049. void   S4FUNCTION c4dtoa45( double, char S4PTR *, int, int) ;
  1050. void   S4FUNCTION c4encode( char S4PTR *, char S4PTR *, char S4PTR *, char S4PTR *) ;
  1051. void   S4FUNCTION c4lower( char S4PTR * ) ;
  1052. void   S4FUNCTION c4ltoa45( long, char S4PTR *, int) ;
  1053. void   S4FUNCTION c4trim_n( char S4PTR *, int ) ;
  1054. void   S4FUNCTION c4upper( char S4PTR * ) ;
  1055.  
  1056. #ifdef S4VBASIC
  1057.    int c4parm_check( void *, int, char * ) ;
  1058. #endif   
  1059.  
  1060. char S4PTR * S4FUNCTION d4alias( D4DATA S4PTR * ) ;
  1061. void   S4FUNCTION d4alias_set( D4DATA S4PTR *, char S4PTR * ) ;
  1062. int    S4FUNCTION d4append( D4DATA S4PTR * ) ;
  1063. int    S4FUNCTION d4append_data( D4DATA S4PTR * ) ;
  1064. int    S4FUNCTION d4append_blank( D4DATA S4PTR * ) ;
  1065. int    S4FUNCTION d4append_start( D4DATA S4PTR *, int ) ;
  1066. void   S4FUNCTION d4blank( D4DATA S4PTR * ) ;
  1067. int    S4FUNCTION d4bof( D4DATA S4PTR * ) ;
  1068. int    S4FUNCTION d4bottom( D4DATA S4PTR * ) ;
  1069. int    S4FUNCTION d4check( D4DATA S4PTR * ) ;
  1070. int    S4FUNCTION d4close( D4DATA S4PTR * ) ;
  1071. int    S4FUNCTION d4close_all( C4CODE S4PTR * ) ;
  1072. int    S4FUNCTION d4commit( D4DATA S4PTR * ) ;
  1073. D4DATA S4PTR * S4FUNCTION d4create( C4CODE S4PTR *, char S4PTR *, F4FIELD_INFO S4PTR *, T4TAG_INFO S4PTR * ) ;
  1074. D4DATA S4PTR * S4FUNCTION d4data( C4CODE S4PTR *, char S4PTR * ) ;
  1075. void   S4FUNCTION d4delete( D4DATA S4PTR * ) ;
  1076. int    S4FUNCTION d4deleted( D4DATA S4PTR * ) ;
  1077. int    S4FUNCTION d4eof( D4DATA S4PTR * ) ;
  1078. F4FIELD S4PTR * S4FUNCTION d4field( D4DATA S4PTR *, char S4PTR * ) ;
  1079. F4FIELD S4PTR * S4FUNCTION d4field_j( D4DATA S4PTR *, int ) ;
  1080. int    S4FUNCTION d4field_number( D4DATA S4PTR *, char S4PTR * ) ;
  1081. int    S4FUNCTION d4flush_all( D4DATA S4PTR * ) ;
  1082. int    S4FUNCTION d4flush_record( D4DATA S4PTR * ) ;
  1083. int    S4FUNCTION d4free_blocks( D4DATA S4PTR * ) ;
  1084. int    S4FUNCTION d4go( D4DATA S4PTR *, long ) ;
  1085. int    S4FUNCTION d4go_data( D4DATA S4PTR *, long ) ;
  1086. int    S4FUNCTION d4go_eof( D4DATA S4PTR * ) ;
  1087. I4INDEX S4PTR * S4FUNCTION d4index( D4DATA S4PTR *, char S4PTR * ) ;
  1088. void   S4FUNCTION d4init( C4CODE S4PTR * ) ;
  1089. int    S4FUNCTION d4init_undo( C4CODE S4PTR * ) ;
  1090. int    S4FUNCTION d4lock( D4DATA S4PTR *, long ) ;
  1091. int    S4FUNCTION d4lock_append( D4DATA S4PTR * ) ;
  1092. int    S4FUNCTION d4lock_file( D4DATA S4PTR * ) ;
  1093. int    S4FUNCTION d4lock_index( D4DATA S4PTR * ) ;
  1094. int    S4FUNCTION d4lock_group( D4DATA S4PTR *, long S4PTR *, int ) ;
  1095. int    S4FUNCTION d4lock_test( D4DATA S4PTR *, long ) ;
  1096. int    S4FUNCTION d4lock_test_file( D4DATA S4PTR * ) ;
  1097. int    S4FUNCTION d4lock_test_append( D4DATA S4PTR * ) ;
  1098. int    S4FUNCTION d4memo_compress( D4DATA S4PTR * ) ;
  1099. int    S4FUNCTION d4num_fields ( D4DATA S4PTR * ) ;
  1100. D4DATA S4PTR *S4FUNCTION d4open( C4CODE S4PTR *, char S4PTR * ) ;
  1101. int    S4FUNCTION d4pack( D4DATA S4PTR * ) ;
  1102. int    S4FUNCTION d4pack_data( D4DATA S4PTR * ) ;
  1103. int    S4FUNCTION d4position2( D4DATA S4PTR *, double S4PTR * ) ;
  1104. double S4FUNCTION d4position( D4DATA S4PTR * ) ;
  1105. int    S4FUNCTION d4position_set( D4DATA S4PTR *, double ) ;
  1106. int    S4FUNCTION d4read( D4DATA S4PTR *, long, char S4PTR * ) ;
  1107. int    S4FUNCTION d4read_old( D4DATA S4PTR *, long ) ;
  1108. void   S4FUNCTION d4recall( D4DATA S4PTR * ) ;
  1109. long   S4FUNCTION d4reccount( D4DATA S4PTR * ) ;
  1110. long   S4FUNCTION d4recno( D4DATA S4PTR * ) ;
  1111. char  S4PTR *S4FUNCTION d4record( D4DATA S4PTR * ) ;
  1112. long   S4FUNCTION d4record_width( D4DATA S4PTR * ) ;
  1113. long   S4FUNCTION d4rec_pos( D4DATA S4PTR *, long ) ;
  1114. int    S4FUNCTION d4reindex( D4DATA S4PTR * ) ;
  1115. int    S4FUNCTION d4seek( D4DATA S4PTR *, char S4PTR * ) ;
  1116. int    S4FUNCTION d4seek_double( D4DATA S4PTR *, double ) ;
  1117. int    S4FUNCTION d4skip( D4DATA S4PTR *, long ) ;
  1118. T4TAG S4PTR *S4FUNCTION d4tag( D4DATA S4PTR *, char S4PTR * ) ;
  1119. T4TAG S4PTR *S4FUNCTION d4tag_default( D4DATA S4PTR * ) ;
  1120. T4TAG S4PTR *S4FUNCTION d4tag_next( D4DATA S4PTR *, T4TAG S4PTR * ) ;
  1121. T4TAG S4PTR *S4FUNCTION d4tag_prev( D4DATA S4PTR *, T4TAG S4PTR * ) ;
  1122. void   S4FUNCTION d4tag_select( D4DATA S4PTR *, T4TAG S4PTR * ) ;
  1123. T4TAG S4PTR *S4FUNCTION d4tag_selected( D4DATA S4PTR * ) ;
  1124. int    S4FUNCTION d4top( D4DATA S4PTR * ) ;
  1125. int    S4FUNCTION d4unlock_all( D4DATA S4PTR * ) ;
  1126. int    S4FUNCTION d4unlock_all_data( D4DATA S4PTR * ) ;
  1127. int    S4FUNCTION d4unlock_append( D4DATA S4PTR * ) ;
  1128. int    S4FUNCTION d4unlock_file( D4DATA S4PTR * ) ;
  1129. int    S4FUNCTION d4unlock_index( D4DATA S4PTR * ) ;
  1130. int    S4FUNCTION d4unlock_records( D4DATA S4PTR * ) ;
  1131. int    S4FUNCTION d4update_header( D4DATA S4PTR *, int, int ) ;
  1132. int    S4FUNCTION d4validate_memo_ids( D4DATA S4PTR * ) ;
  1133. int    S4FUNCTION d4write( D4DATA S4PTR *, long ) ;
  1134. int    S4FUNCTION d4write_data( D4DATA S4PTR *, long ) ;
  1135. int    S4FUNCTION d4write_keys( D4DATA S4PTR *, long ) ;
  1136. int    S4FUNCTION d4zap( D4DATA S4PTR *, long, long ) ;
  1137. int    S4FUNCTION d4zap_data( D4DATA S4PTR *, long, long ) ;
  1138.  
  1139. int    S4FUNCTION e4error_set( C4CODE S4PTR *, int ) ;
  1140. void   S4FUNCTION e4exit(C4CODE S4PTR *) ;
  1141. void   S4FUNCTION e4exit_test( C4CODE S4PTR * ) ;
  1142.  
  1143. #ifdef S4VARARGS
  1144.    int    S4ERROR    e4error( ) ;
  1145.    void   S4ERROR    e4severe( ) ;
  1146. #else
  1147.    int    S4ERROR    e4error( C4CODE S4PTR *, int, char *, ... ) ;
  1148.    void   S4ERROR    e4severe( int, char *, ... ) ;
  1149.    #ifdef S4VBASIC
  1150.       void   S4ERROR   e4severe_vbasic( int, char *, ... ) ;
  1151.    #endif
  1152. #endif
  1153.  
  1154. void   S4FUNCTION f4assign( F4FIELD S4PTR *, char S4PTR * ) ;
  1155. void   S4FUNCTION f4assign_char( F4FIELD S4PTR *, int ) ;
  1156. void   S4FUNCTION f4assign_double( F4FIELD S4PTR *, double ) ;
  1157. void   S4FUNCTION f4assign_int( F4FIELD S4PTR *, int ) ;
  1158. void   S4FUNCTION f4assign_long( F4FIELD S4PTR *, long ) ;
  1159. void   S4FUNCTION f4assign_n( F4FIELD S4PTR *, char S4PTR *, unsigned ) ;
  1160. char S4PTR * S4FUNCTION f4assign_ptr( F4FIELD S4PTR * ) ;
  1161. void   S4FUNCTION f4blank( F4FIELD S4PTR * ) ;
  1162. int    S4FUNCTION f4char( F4FIELD S4PTR * ) ;
  1163. D4DATA S4PTR *S4FUNCTION f4data( F4FIELD S4PTR * ) ;
  1164. int    S4FUNCTION f4decimals( F4FIELD S4PTR * ) ;
  1165. int    S4FUNCTION f4double2( F4FIELD S4PTR *, double S4PTR * ) ;
  1166. double S4FUNCTION f4double( F4FIELD S4PTR * ) ;
  1167. int    S4FUNCTION f4int( F4FIELD S4PTR * ) ;
  1168. unsigned  S4FUNCTION f4len( F4FIELD S4PTR * ) ;
  1169. long   S4FUNCTION f4long( F4FIELD S4PTR * ) ;
  1170. char S4PTR * S4FUNCTION f4name( F4FIELD S4PTR * ) ;
  1171. unsigned S4FUNCTION f4ncpy( F4FIELD S4PTR *, char S4PTR *, unsigned ) ;
  1172. char S4PTR * S4FUNCTION f4ptr( F4FIELD S4PTR * ) ;
  1173. char S4PTR * S4FUNCTION f4str( F4FIELD S4PTR * ) ;
  1174. int    S4FUNCTION f4true( F4FIELD S4PTR * ) ;
  1175. int    S4FUNCTION f4type( F4FIELD S4PTR * ) ;
  1176.  
  1177. int    S4FUNCTION h4close( H4FILE S4PTR * ) ;
  1178. int    S4FUNCTION h4create( H4FILE S4PTR *, C4CODE S4PTR *, char S4PTR *, int ) ;
  1179. long   S4FUNCTION h4length( H4FILE S4PTR * ) ;
  1180. int    S4FUNCTION h4length_set( H4FILE S4PTR *, long ) ;
  1181. int    S4FUNCTION h4lock( H4FILE S4PTR *, long, long ) ;
  1182. int    S4FUNCTION h4open( H4FILE S4PTR *, C4CODE S4PTR *, char S4PTR *, int ) ;
  1183. int    S4FUNCTION h4open_test( H4FILE S4PTR * ) ;
  1184. unsigned  S4FUNCTION h4read( H4FILE S4PTR *, long, void S4PTR *, unsigned ) ;
  1185. int    S4FUNCTION h4read_all( H4FILE S4PTR *, long, void S4PTR *, unsigned ) ;
  1186. int    S4FUNCTION h4read_error( H4FILE S4PTR * ) ;
  1187. int    S4FUNCTION h4replace( H4FILE S4PTR *, H4FILE S4PTR * ) ;
  1188. int    S4FUNCTION h4temp( H4FILE S4PTR *, C4CODE S4PTR *, char S4PTR *, int ) ;
  1189. int    S4FUNCTION h4unlock( H4FILE S4PTR *, long, long ) ;
  1190. int    S4FUNCTION h4write( H4FILE S4PTR *, long, void S4PTR *, unsigned ) ;
  1191.  
  1192. void   S4FUNCTION h4seq_read_init( H4SEQ_READ S4PTR *, H4FILE S4PTR *, long, void S4PTR *, unsigned ) ;
  1193. unsigned  S4FUNCTION h4seq_read( H4SEQ_READ S4PTR *, void S4PTR *, unsigned ) ;
  1194. int    S4FUNCTION h4seq_read_all( H4SEQ_READ S4PTR *, void S4PTR *, unsigned ) ;
  1195.  
  1196. void   S4FUNCTION h4seq_write_init( H4SEQ_WRITE S4PTR *, H4FILE S4PTR *, long, void S4PTR *, unsigned ) ;
  1197. int    S4FUNCTION h4seq_write( H4SEQ_WRITE S4PTR *, void S4PTR *, unsigned ) ;
  1198. int    S4FUNCTION h4seq_write_flush( H4SEQ_WRITE S4PTR * ) ;
  1199. int    S4FUNCTION h4seq_write_repeat( H4SEQ_WRITE S4PTR *, long, char ) ;
  1200.  
  1201. int    S4FUNCTION i4check( I4INDEX S4PTR * ) ;
  1202. int    S4FUNCTION i4close( I4INDEX S4PTR * ) ;
  1203. I4INDEX S4PTR *S4FUNCTION i4create( D4DATA S4PTR *, char S4PTR *, T4TAG_INFO S4PTR * ) ; /* 0 name -> productn */
  1204. long   S4FUNCTION i4extend( I4INDEX S4PTR * ) ;   /* Allocates a block at the end of the file */
  1205. int    S4FUNCTION i4flush( I4INDEX S4PTR * ) ;
  1206. int    S4FUNCTION i4lock( I4INDEX S4PTR * ) ;
  1207. I4INDEX S4PTR *S4FUNCTION i4open( D4DATA S4PTR *, char S4PTR * ) ;
  1208. int    S4FUNCTION i4reindex( I4INDEX S4PTR * ) ;
  1209. int    S4FUNCTION i4shrink( I4INDEX S4PTR *, long ) ;  /* Returns a block of disk space */
  1210. T4TAG S4PTR *S4FUNCTION i4tag( I4INDEX S4PTR *, char S4PTR * ) ;
  1211. int    S4FUNCTION i4unlock( I4INDEX S4PTR * ) ;
  1212. int    S4FUNCTION i4update_header( I4INDEX S4PTR * ) ;
  1213. int    S4FUNCTION i4version_check( I4INDEX S4PTR * ) ;
  1214.  
  1215. void   S4FUNCTION l4add( L4LIST S4PTR *, void S4PTR * ) ;
  1216. void   S4FUNCTION l4add_after(   L4LIST S4PTR *, void S4PTR *, void S4PTR * ) ;
  1217. void   S4FUNCTION l4add_before( L4LIST S4PTR *, void S4PTR *, void S4PTR * ) ;
  1218. void   l4check( L4LIST S4PTR * ) ;
  1219. void S4PTR * S4FUNCTION l4first( L4LIST S4PTR * ) ;  /* Returns 0 if none */
  1220. void S4PTR * S4FUNCTION l4last( L4LIST S4PTR * ) ;   /* Returns 0 if none */
  1221. void S4PTR * S4FUNCTION l4next( L4LIST S4PTR *, void S4PTR * ) ;  /* Returns 0 if none */
  1222. void S4PTR * S4FUNCTION l4prev( L4LIST S4PTR *, void S4PTR * ) ;
  1223. void S4PTR * S4FUNCTION l4pop( L4LIST S4PTR * ) ;
  1224. void   S4FUNCTION l4remove( L4LIST S4PTR *, void S4PTR * ) ;
  1225.  
  1226. int    S4FUNCTION l4lock_check( void ) ;
  1227. void   l4lock_remove( int,long,long) ;
  1228. void   l4lock_save( int,long,long) ;
  1229.  
  1230. #ifndef S4MFOX
  1231. #ifndef S4MNDX
  1232. int    m4file_chain_flush( M4FILE S4PTR *, M4CHAIN_ENTRY S4PTR * ) ;
  1233. int    m4file_chain_skip( M4FILE S4PTR *, M4CHAIN_ENTRY S4PTR * ) ;
  1234. int    S4FUNCTION m4check( M4FILE S4PTR * ) ;
  1235. #endif  /*  ifndef S4MFOX  */
  1236. #endif  /*  ifndef S4MNDX  */
  1237.  
  1238. int    m4file_check( M4FILE S4PTR * ) ;
  1239. int    m4file_create( M4FILE S4PTR *, C4CODE S4PTR *, D4DATA S4PTR *, char S4PTR * );
  1240.           /* if (name == 0), it is a temporary file */
  1241. int    m4file_dump( M4FILE S4PTR *, long, char S4PTR *, unsigned ) ; 
  1242. int    m4file_open( M4FILE S4PTR *, D4DATA S4PTR *, char S4PTR * ) ;
  1243. int    m4file_read( M4FILE S4PTR *, long , char S4PTR **, unsigned S4PTR * ) ;
  1244. int    m4file_write( M4FILE S4PTR *, long S4PTR *, char S4PTR *, unsigned ) ; /* Pass the old id */
  1245.  
  1246. int    S4FUNCTION m4assign( F4FIELD S4PTR *, char S4PTR * ) ;
  1247. int    S4FUNCTION m4assign_n( F4FIELD S4PTR *, char S4PTR *, unsigned ) ;
  1248. unsigned S4FUNCTION m4len( F4FIELD S4PTR * ) ;
  1249. unsigned S4FUNCTION m4ncpy( F4FIELD S4PTR *, char S4PTR *, unsigned ) ;
  1250. int    S4FUNCTION m4set_len( F4FIELD S4PTR *, unsigned ) ;
  1251. char   S4PTR * S4FUNCTION m4str( F4FIELD S4PTR * ) ;
  1252. char   S4PTR * S4FUNCTION m4ptr( F4FIELD S4PTR * ) ;
  1253.  
  1254. int    S4FUNCTION m4flush( F4FIELD S4PTR * ) ;
  1255. void   S4FUNCTION m4free( F4FIELD S4PTR * ) ;
  1256. int    S4FUNCTION m4read( F4FIELD S4PTR * ) ;       /* Validates memo id's first */
  1257. int    S4FUNCTION m4read_low( F4FIELD S4PTR * ) ;   /* Assumes the current memo id is valid */
  1258. void   S4FUNCTION m4reset( F4FIELD S4PTR * ) ;      /* Resets to 'Unknown state' */
  1259. int    S4FUNCTION m4write( F4FIELD S4PTR * ) ;
  1260.  
  1261. int    S4FUNCTION t4add( T4TAG S4PTR *, unsigned char S4PTR *, long ) ;  /* Returns r4unique, r4success, r4repeat */
  1262. int    S4FUNCTION t4add_calc( T4TAG S4PTR *, long ) ; /* Calculates expression and adds */
  1263. B4BLOCK S4PTR *S4FUNCTION t4block( T4TAG S4PTR * ) ;
  1264. int    S4FUNCTION t4bottom( T4TAG S4PTR * ) ;
  1265. int    S4FUNCTION t4check( T4TAG S4PTR * ) ;
  1266. int    S4FUNCTION t4down( T4TAG S4PTR * ) ;
  1267. int    S4FUNCTION t4dump( T4TAG S4PTR *, int, int ) ;
  1268. int    S4FUNCTION t4eof( T4TAG S4PTR * ) ;
  1269. int    S4FUNCTION t4flush( T4TAG S4PTR * ) ;
  1270. int    S4FUNCTION t4free_all( T4TAG S4PTR * ) ;
  1271. int    S4FUNCTION t4free_saved( T4TAG S4PTR * ) ;
  1272. int    S4FUNCTION t4go( T4TAG S4PTR *, char S4PTR *, long ) ;
  1273. void   S4FUNCTION t4init_seek_conv( T4TAG S4PTR *, int) ;    /* Initialize 'stok' and 'dtok' */
  1274. B4KEY_DATA S4PTR *S4FUNCTION t4key( T4TAG S4PTR * ) ;              /* The current key */
  1275. int    S4FUNCTION t4lock( T4TAG S4PTR * ) ;
  1276. int    S4FUNCTION t4position2( T4TAG S4PTR *, double S4PTR * ) ;     
  1277. double S4FUNCTION t4position( T4TAG S4PTR * ) ;              /* Returns the position as a percent */
  1278. int    S4FUNCTION t4position_set( T4TAG S4PTR *, double ) ;  /* Positions a percentage */
  1279. long   S4FUNCTION t4recno( T4TAG S4PTR * ) ;
  1280. int    S4FUNCTION t4remove_current( T4TAG S4PTR * ) ;        /* Remove the current key */
  1281. int    S4FUNCTION t4remove( T4TAG S4PTR *, char S4PTR *, long ) ;  /* Remove specified key */
  1282. int    S4FUNCTION t4remove_calc( T4TAG S4PTR *, long ) ; /* Calculates expression and removes */
  1283. int    S4FUNCTION t4seek( T4TAG S4PTR *, void S4PTR *, int ) ;    /* r4success, r4found, r4after, r4eof */
  1284. long   S4FUNCTION t4skip( T4TAG S4PTR *, long ) ;
  1285. B4BLOCK S4PTR *S4FUNCTION t4split( T4TAG S4PTR *, B4BLOCK S4PTR * ) ;
  1286. int    S4FUNCTION t4top( T4TAG S4PTR * ) ;
  1287. int    S4FUNCTION t4type( T4TAG S4PTR * ) ;
  1288. int    S4FUNCTION t4up( T4TAG S4PTR * ) ;
  1289. int    S4FUNCTION t4up_to_root( T4TAG S4PTR * ) ;
  1290.  
  1291. /* File name lengths include one extra null character at end */
  1292. int    S4FUNCTION u4name_char( unsigned char ) ;
  1293. void   S4FUNCTION u4name_ext( char S4PTR *, int, char S4PTR *, int ) ;
  1294. void   S4FUNCTION u4name_piece( char S4PTR *, int, char S4PTR *, int, int ) ;
  1295. int    S4FUNCTION u4name_path( char S4PTR *, int, char S4PTR * ) ;
  1296.  
  1297. unsigned S4FUNCTION u4ncpy( char S4PTR *, char S4PTR *, unsigned ) ;
  1298. int    S4FUNCTION u4ptr_equal( void S4PTR *, void S4PTR * ) ;
  1299. int    S4FUNCTION u4remove( char S4PTR * ) ;
  1300. void   S4FUNCTION u4yymmdd( char S4PTR * ) ;
  1301. int    S4FUNCTION u4rename( char S4PTR *, char S4PTR * ) ;
  1302.  
  1303. #ifdef S4CLIPPER
  1304.    char S4PTR * S4FUNCTION u4descend_char(char S4PTR*);
  1305.    char S4PTR * S4FUNCTION u4descend_date(char S4PTR*);
  1306.    char S4PTR * S4FUNCTION u4descend_num(char S4PTR*);
  1307.    char S4PTR * S4FUNCTION u4descend(F4FIELD S4PTR*);
  1308. #endif
  1309.  
  1310. void  S4PTR *S4FUNCTION u4alloc( long ) ;
  1311. int    S4FUNCTION u4alloc_again( C4CODE S4PTR *, char S4PTR **, unsigned S4PTR *, unsigned ) ;
  1312. void   S4FUNCTION u4free( void S4PTR * ) ;
  1313. short  S4FUNCTION x4reverse_short( short ) ;
  1314. long   S4FUNCTION x4reverse_long( long ) ;
  1315.  
  1316. void  S4PTR *S4FUNCTION y4alloc( Y4MEMORY_TYPE S4PTR * ) ;  /* 0 Parm causes 0 return */
  1317. Y4CHUNK S4PTR *S4FUNCTION y4alloc_chunk( Y4MEMORY_TYPE S4PTR * ) ;  /* 0 Parm causes 0 return */
  1318. void   S4FUNCTION y4free( Y4MEMORY_TYPE S4PTR *, void S4PTR * ) ;
  1319. int    S4FUNCTION y4free_check( int ) ;
  1320. void   S4FUNCTION y4check_memory( void ) ;
  1321. void   S4FUNCTION y4init( void ) ;
  1322. Y4MEMORY_TYPE S4PTR *S4FUNCTION y4memory_type( int, unsigned, int, int ) ;
  1323. void  S4PTR *S4FUNCTION y4memory_type_alloc( Y4MEMORY_TYPE S4PTR **, int, unsigned, int, int ) ;
  1324. void   S4FUNCTION y4release( Y4MEMORY_TYPE S4PTR * ) ;
  1325. void   S4FUNCTION y4reset( void ) ;
  1326.  
  1327. #ifdef __cplusplus
  1328.    }
  1329. #endif
  1330.  
  1331. int S4CALL c4bcd_cmp( S4CMP_PARM, S4CMP_PARM, size_t ) ;
  1332. int S4CALL u4memcmp( S4CMP_PARM, S4CMP_PARM, size_t ) ;
  1333.  
  1334.  
  1335.