1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #ifndef SP_VAR_H
- #define SP_VAR_H
- #pragma once
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include "sp_uid.h"
- #define VAR_RSERVERD_KEY_TERM_STATE "{314A6884-6373-48AD-A800-AE8E866E3572}"
- /* variable support, sub/unsub notification support */
- typedef struct sp_var_client_t sp_var_client_t;
- typedef struct sp_var_listener_t sp_var_listener_t;
- typedef struct sp_var_daemon_t sp_var_daemon_t;
- typedef struct sp_svc_t sp_svc_t;
- typedef void (*sp_var_on_change)(sp_var_listener_t *listener,
- const char *key,
- const char *oldstr,
- const char *newstr,
- int client_id,
- void *user_data);
- // client
- SPBASE_API int sp_var_client_create(sp_svc_t *svc, sp_var_client_t **p_client);
- SPBASE_API void sp_var_client_destroy(sp_var_client_t *client);
- SPBASE_API int sp_var_client_set(sp_var_client_t *client, const char *key, const char *str, int persist);
- int sp_var_client_get(sp_var_client_t *client, const char *key, char *str, int *n);
- int sp_var_client_lock(sp_var_client_t *client);
- int sp_var_client_unlock(sp_var_client_t *client);
- // listener
- int sp_var_listener_create(sp_svc_t *svc, const char *key, sp_var_on_change on_change, void *user_data, sp_var_listener_t **p_listener);
- void sp_var_listener_destroy(sp_var_listener_t *listener);
- int sp_var_listener_subscribe(sp_var_listener_t *listener);
- int sp_var_listener_unsubscribe(sp_var_listener_t *listener);
- void sp_var_listener_set_tag(sp_var_listener_t *listener, void *tag);
- void* sp_var_listener_get_tag(sp_var_listener_t *listener);
- int sp_var_listener_enable(sp_var_listener_t *listener, int enabled);
- // daemon
- SPBASE_API int sp_var_daemon_create(sp_svc_t *svc, sp_var_daemon_t **p_daemon);
- SPBASE_API void sp_var_daemon_destroy(sp_var_daemon_t *daemon);
- #ifdef __cplusplus
- } // extern "C" {
- #endif
- #endif // SP_VAR_H
|