Back to libut API Reference


    #include "libut/ut.h"
    int UT_var_reg_cb( char *name, UT_var_upd_cb *cb, void *data );


This function registers a callback cb to be invoked whenever the value of the configuration variable with the given name is set using UT_var_set(3) or using the var command in the control port or the configuration file.

The callback specified by the cb function pointer must have this prototype: int (UT_var_upd_cb)(char *name, void *data);

When invoked the callback will be passed the name of the configuration variable and the data pointer, which is an opaque value. The callback can read the value of the variable using UT_var_get(3). The callback must return a value greater than or equal to 0 to accept this value, or less than zero to reject it. The idea is that the callback can enforce some conditions on the value of the variable. If the value is rejected, the original value is retained.

More than one callback can be registered for a configuration variable. In this scenario, if any callback rejects the value, the old value is retained (and any callbacks that were already invoked will be invoked again, and they must accept the original value that was restored).


The function always returns 0.


The var control port command lists and sets the configuration variables.


UT_var_create(3), UT_var_set(3), UT_var_get(3), UT_var_bindc(3), UT_var_restrict(3)


Troy D. Hanson <>