Can maapi_cli_printf/write be called outside action callback?

I read the UG, it tells the function is called from inside an action callback.

this function is intended to be called from inside an action callback when invoked from the CLI

I want to show some debug info to CLI actively during the daemon running, so how could I implement this?

You can refer to the ConfD User Guide for the man pages of the following API calls:

- maapi_user_message( )

- maapi_sys_message( )

- maapi_prio_message( )

Thank you very much, it works!

@waitai

Another question, since maapi_user/sys/prio_message() could output message into CLI both inside and outside an action, why there are still APIs of maapi_printf/write() functions? What’s the difference between them?

An actionpoint callback receive the confd_user_info *uinfo parameter that can be used with the maapi_cli_print/write functions to print to the CLI user that requested the action.

which socket need maapi_cli_printf ? I have this error : DEBUG Failed to write 30 bytes to ConfD: Bad file descriptor

Have a look at the examples.confd/cli/c_cli/actions.c example. You have to create a new socket and maapi_connect() it.