FastSort Manual

Sorting Programmatically
FastSort Manual429834-003
4-10
Sorting From C Programs
/*-------------------------------------------------------------*/
/* FastSort error and statistics variables. */
/*-------------------------------------------------------------*/
short error; /* error return parameter */
_lowmem short error_buf[20], /* error message buffer */
error_source[20];/* error related info */
_lowmem long error_code[40]; /* Fastsort & system error codes*/
struct sortstats_template {
short maxrecordsize;
short bufferpages;
long records;
long elapsedtime;
long compares;
long scratchseeks;
long iowaittime;
long scratchfileeof;
long initialruns;
short firstmergeorder;
short mergeorder;
short intermediatepasses;
long numberofduplicates;
} _lowmem sortstats;
void error_handler (void);
short DisplaySortStatistics (struct sortstats_template *);
*-------------------------------------------------------------*/
#pragma page " Main logic "
/*-------------------------------------------------------------*/
int main (void)
{
short length = 2;
short errlen = 0;
short index;
_lowmem short actuallen;/* for size of statistics in words */
/*-------------------------------------------------------------*/
/* Perform standard initialization. */
/*-------------------------------------------------------------*/
error = PROCESS_GETINFO_(,,,,,,&home_term_name,
home_term_maxlen,
&home_term_len,
,,,,,,,,,,,&error_detail);
if (error)
DEBUG;
if (FILE_OPEN_(home_term_name,
home_term_len,
&home_term_filenum) != CCE )
DEBUG;
INITIALIZER; /* read the startup message */
/*-------------------------------------------------------------*/
/* Initialize SORT key definitions array. */
/*-------------------------------------------------------------*/
key_array[0] = 1; /* number of keys */
key_array[1] = 2; /* definition = binary, unsigned, ascending*/
key_array[2] = 2; /* key length = 2 bytes */
key_array[3] = 0; /* key offset = 0 bytes */
Example 4-1. C Example of a Serial Sort Run (page2of5)