shsettings

Library used to store reboot persistent-settings. You can subscribe to get notifications when a setting is updated.

SHS_API struct shs_ctx *shs_ctx_new_client(shs_change_cb_t cb, void *userdata)

Create a context that will be used as client. It means it will be able to synchronize settings with other processes.

Parameters:
  • cb – : function to call when a subscribed setting is changed.

  • userdata – : user data to be given back in cb.

SHS_API int shs_ctx_destroy(struct shs_ctx *ctx)

Destroy the context. It must be previously stopped.

Parameters:

ctx

SHS_API int shs_ctx_start(struct shs_ctx *ctx)

Start the context. It will internally creates sockets based of server/client role and subscribed settings. For servers, it will load default settings from:

  • ’/etc/libshsettings/<rootname>.cfg’

  • ’/var/lib/libshsettings/<rootname>.cfg’ Sockets will be unix domain stored in tmpfs (for easy introspection):

  • ’/tmp/libshsettings/<rootname>.socket’

Parameters:

ctx

SHS_API int shs_ctx_stop(struct shs_ctx *ctx)

Stop the context. It will internally destroy all sockets.

Parameters:

ctx

SHS_API int shs_ctx_subscribe(struct shs_ctx *ctx, const char *name, shs_change_cb_t cb, void *userdata)

Subscribe to a setting to be able to get its value, be notified of changes and modify the value. This function can also be called by clients and servers contexts. Can only be called BEFORE the context is started.

Remark

: ‘<rootname>.*’ is recognized to subscribe to ALL settings of a given server.

Remark

: ‘*’ is recognized to subscribe to ALL settings of ALL running servers (periodically checked).

Parameters:
  • ctx

  • name – : full name of setting to subscribe to. The first component will be the root name and will identify the socket associated with the server.

SHS_API int shs_ctx_set(struct shs_ctx *ctx, const char *name, const struct shs_value *val)

Modify the value of a setting. For servers, it will notify clients that have subscribed to the setting. For clients, it will send the value to a remote process that will ultimately notify the client back when change is done.

Parameters:

ctx

SHS_API int shs_ctx_pomp_loop_register(struct shs_ctx *ctx, struct pomp_loop *loop)

Register a context to a pomp loop

SHS_API int shs_ctx_pomp_loop_unregister(struct shs_ctx *ctx, struct pomp_loop *loop)

Unregister a context from a pomp loop