Chapter 2. LqR library API user manual
Prev |  | Next

# Chapter 2. LqR library API user manual

## Signal handling

Many library functions return a value of type `LqrRetVal`. This is an enum type which can hold the values:

`LQR_OK`

  everyting OK

`LQR_ERROR`

  generic fatal error

`LQR_NOMEM`

  not enough memory

`LQR_USRCANCEL`

  action cancelled by the user

At top level, it is important that the user handle these values explicitly, because the library functions don't do anything else than stopping and returning an error signal in case of errors. An easy way is setting up some macros and wrap each function call with those, as shown in the example files.

Below top level, the library provides some convenient macros which can be used to wrap function calls, in order to propagate these signals:

``LQR_CATCH` (`expr`)`

  if `expr` is equal to `LQR_OK` it does nothing, otherwise it returns `expr` (or the result of the execution of `expr` if it happens to be a function)

``LQR_CATCH_F` (`expr`)`

  returns `LQR_ERROR` if `expr` is `FALSE`

``LQR_CATCH_MEM` (`expr`)`

  returns `LQR_NOMEM` if `expr` is `NULL`

### Note

The names of these macros have changed since version `0.4`; the previous names `CATCH`, `CATCH_F` and `CATCH_MEM` are still available, but they can be disabled at configure time if they cause conflicts (configure --help for details).

Prev |  | Next
Basic methods | Home | Generating the multi-size image