long KCssAPI KCssSetError( /* set/add error text */
KCssHandle aHandle, /* CSS handle */
const char *aBuffer, /* buffer for result */
long aSize /* buffer size, -1 = ASCIZ */
);
Set/add an error text. This function is used in C/C++ function implementions to raise an error. KCssSetError may be called multiple to add several texts. KCssSetError will allways return 0 so there is no need for error checking. Example: void KCssAPI mthSqrt(KCssHandle aCss)
{
char buf[40];
long bufsiz;
// get val
bufsiz = sizeof(buf);
if ( KCssGet(aCss, "val", buf, &bufsiz) ) return;
double val = atof(buf);
if (val < 0.0) {
KCssSetError(aCss, "val must not be negative!", -1);
return;
} // if
// return result
sprintf(buf, "%f", sqrt(val));
KCssSetResult(aCss, buf, -1);
} // mthSqrt
|