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.

void cs_end(void)

Memory that is implicitly allocated (CSint variable creation, constraint declaration, …) between cs_init() and cs_end() is freed when cs_end() is called.

CSint variables should not be accessed after cs_end().

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() or cs_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.

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

const char *cs_getVersion(void)

Returns version string of iZ-C. (ex: “3.5.0”)

This string is equivarent to which is concatinated these following values using “.”.

IZ_VERSION_MAJOR

Major version of iZ-C

IZ_VERSION_MINOR

Minor version of iZ-C

IZ_VERSION_PATCH

Patch level of iZ-C

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() and cs_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.