long ZCslSetError( /* set/add error text */
ZCslHandle aHandle, /* CSL 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 implementations
to raise an error. ZCslSetError may be called multiple to add several
texts.
ZCslSetError will always return 0 so there is no need for error checking.
Example:
ZExportAPI(void) mthSqrt(ZCslHandle aCsl)
{
char buf[40];
long bufsiz;
double val;
/* get val */
bufsiz = sizeof(buf);
if ( ZCslGet(aCsl, "val", buf, &bufsiz) ) return;
val = atof(buf);
if (val < 0.0) {
ZCslSetError(aCsl, "val must not be negative!", -1);
return;
} /* if */
/* return result */
sprintf(buf, "%f", sqrt(val));
ZCslSetResult(aCsl, buf, -1);
} /* mthSqrt */
|