KCMS Application Developer's Guide

KcsSetCallback()

KcsStatusId
 KcsSetCallback (KcsFunction function,
         KcsCallbackFunction callback, void *userDefinedData)

Purpose

Use KcsSetCallback() to associate a callback function with any set of API functions that supports callbacks. Those functions are listed in KcsFunction (see Table 3-1). If KcsSetCallback() is not called for particular values of KcsFunction, no callback is issued.

This function allocates resources. To release those resources, your application must set all callback functions to NULL, for example,

KcsSetCallback(KcsAllFunc, NULL, NULL);

Arguments

Table 4-25 KcsSetCallback() Arguments

Argument  

Description  

function  

A set of API functions. See Table 3-1 for the list of functions.

callback  

The application-supplied function to be called when the variable function needs to report progress.

userDefinedData  

Any user-defined data. 

Returns

Table 4-26 KcsSetCallback() Return Strings

KCS_SUCCESS

KCS_MEM_ALLOC_ERROR 

Example


Example 4-12 KcsSetCallback()

/* template function declaration */

 int myProgressCallback(KcsProfileId profileid, unsigned long
             current, unsigned long total, KcsFunction
             operation, void *userDefinedData);

 KcsProfileId                        completeProfile;
 KcsPixelLayout     pixelLayoutIn;

 /* the profiles have been loaded and connected, now set up the
 * callback to be active for both the optimize and evaluate
 * functions */

 status = KcsSetCallback(KcsOptFunc + KcsEvalFunc,
             (KcsCallbackFunction)myProgressCallback, NULL );
 if (status != KCS_SUCCESS) {
     fprintf(stderr, "Callback function call failed\n");
 }
 
 printf("Optimizing the complete profile \n");
 status = KcsOptimizeProfile(completeProfile, KcsOptSpeed, KcsLoadAllNow);
 /* check status here*/
 /* set up the pixel layout */
 status = KcsEvaluate(completeProfile, op, &pixelLayoutIn, &pixelLayoutIn);
 /* check status here*/

 /* This is my callback function */

 int myProgressCallback(KcsProfileId profileid, unsigned long current,
         unsigned long total, KcsFunction operation, void *userDefinedData)

 {
     int            pcent;
 
     pcent = (int) (((float)current/ (float)total) *100.0);
     fprintf(stderr,"Optimize+Evaluate is %3d percent complete\n", pcent);
     fflush(stderr);
     return(KCS_SUCCESS);
 /* Free callback resources*/
 KcsSetCallback (KcsOptFunc+KcsEvalFunc, NULL, NULL);
 }