Execution Environment
Initialize and Finalize
cs_init()
must be called before iZ-C API functions.
And cs_end()
must be called when before program is terminated.
-
void cs_init(void)
Set up internal memory for iZ-C.
Error status
iZ-C library has a variable to hold error status. Library user can check error by reading this variable. (This varibale is called err in this manual.)
-
void cs_initErr(void)
Internal err variable is initialized by calling cs_initErr(). (the value of err is set to CS_ERR_NONE).
cs_initErr() is called implicitely by
cs_init()
.
-
int cs_getErr(void)
Returns current value of err. If it returns
CS_ERR_NONE
, it means there has been no error raised between the last cs_getErr() orcs_init()
call and this cs_getErr() call.err can be set following values:
-
CS_ERR_NONE
No error has been occured.
-
CS_ERR_GETVALUE
cs_getValue()
is called for non-instantiated variable.
-
CS_ERR_OVERFLOW
Overflow has been occured.
-
CS_ERR_NO_MEMORY
Cannot allocate memory.
-
CS_ERR_NONE
-
void cs_setErr(int code)
Set value of err to code.
Error handler
Function can be registed to handle error. Registered function will be called after err is set when error has occured.
-
void cs_setErrHandler(int code, void (*func)(void *data, void *ext), void *ext)
Register function func as error handler of code. Parameter data will have diffrent value as code (see following table) and parameter ext is same value as cs_setErrHandler is called.
Code |
Data |
Default action |
---|---|---|
CS_ERR_GETVALUE |
Pointer to CSint |
Print message and process is continued. |
CS_ERR_OVERFLOW |
NULL |
Do nohitng and process is continued. |
CS_ERR_NO_MEMORY |
NULL |
Call abort() (process will be terminated) |
Version Information
Output of Statistics Information
-
void cs_printStats(void)
Print statistcs values:
Nb Fails (the number of fails that occurred during the generation process)
Nb Choice Points (the number of instantiations on which it is possible to backtrack)
Heap Size (the size of the heap which saves the context to enable backtrack).
Nb Fails and Nb Choice Points can be accessed directly using the
cs_getNbFails()
andcs_getNbChoicePoints()
.
-
void cs_fprintStats(FILE *f)
It is similar to cs_printStats() except that it takes a pointer to FILE as an argument, and writes to the indicated file when the function is invoked.