FastSort Manual

Sorting Programmatically
FastSort Manual429834-003
4-11
Sorting From C Programs
//*-------------------------------------------------------------*/
/* Call SORTBUILDPARM to initialialize SORTPROG control block. */
/* Request blocked, double-buffered interface. */
/*-------------------------------------------------------------*/
error = SORTBUILDPARM (&ctlblk[0],,,
&block_buffer[0], &block_buffer2[0],
BLOCKLEN);
if (error) /* check for SORTBUILDPARM error */
{
errlen = SORTERRORSUM (&ctlblk[0],
&error_buf[0],
&error_code[0],
&error_source[0]);
error_handler;
return EXIT_FAILURE;
}
/*-------------------------------------------------------------*/
/* Call SORTMERGESTART to start the SORTPROG process. */
/*-------------------------------------------------------------*/
error = SORTMERGESTART (&ctlblk[0],
&key_array[0],,1,,,
pdcount,,,,,,
smflags,,,,,,,,,,
smflags2,,);
if (error) /* check for SORTMERGESTART error */
{
errlen = SORTERRORSUM (&ctlblk[0],
&error_buf[0],
&error_code[0],
&error_source[0]);
error_handler;
return EXIT_FAILURE;
}
/*-------------------------------------------------------------*/
/*Call SORTMERGESEND to send records to SORTPROG.Send successive*/
/* positive values to be returned in the same ascending order. */
/* Call SORTMERGERECEIVE to get sorted records from SORTPROG. */
/*-------------------------------------------------------------*/
length = 2; /* set length of buffer/input rec in bytes*/
/* size dependent on size of key */
for (index = 1; index <= MAXCOUNT; index++)
{
inbuf[0] = index; /* set value to send to SORTPROG */
error = SORTMERGESEND (&ctlblk[0],,
length,,,,
(long) &inbuf[0]);
if (error) /* check for SORTMERGESEND error */
{
errlen = SORTERRORSUM (&ctlblk[0] ,
&error_buf[0],
&error_code[0],
&error_source[0]);
error_handler ;
return EXIT_FAILURE;
}
}
length = -1; /* signal end of records to be sorted */
error = SORTMERGESEND (&ctlblk[0],
,length
,
,
,
,(long) &inbuf[0] );
Example 4-1. C Example of a Serial Sort Run (page3of5)