* Major rewrite of event streams
* If you used old event callbacks API, you need to switch to the streams API
* See clixon_stream.[ch]
* Old streams API which needs to be removed include:
* clicon_log_register_callback()
* subscription_add() --> stream_register()
* backend_notify() and backend_notify_xml() - use stream_notify() instead
* Example uses "NETCONF" stream instead of "ROUTING"
* Added timeout option -t for clixon_netconf - quit after max time.
This commit is contained in:
parent
d7fbe75c9e
commit
98f3cd0e32
31 changed files with 597 additions and 635 deletions
|
|
@ -63,12 +63,11 @@
|
|||
#define LIBCLIXON_API 1
|
||||
|
||||
#include <clixon/clixon_sig.h>
|
||||
#include <clixon/clixon_log.h>
|
||||
#include <clixon/clixon_err.h>
|
||||
#include <clixon/clixon_queue.h>
|
||||
#include <clixon/clixon_hash.h>
|
||||
#include <clixon/clixon_handle.h>
|
||||
#include <clixon/clixon_stream.h>
|
||||
#include <clixon/clixon_log.h>
|
||||
#include <clixon/clixon_yang.h>
|
||||
#include <clixon/clixon_yang_type.h>
|
||||
#include <clixon/clixon_event.h>
|
||||
|
|
@ -76,6 +75,7 @@
|
|||
#include <clixon/clixon_file.h>
|
||||
#include <clixon/clixon_xml.h>
|
||||
#include <clixon/clixon_xml_sort.h>
|
||||
#include <clixon/clixon_stream.h>
|
||||
#include <clixon/clixon_proto.h>
|
||||
#include <clixon/clixon_proto_client.h>
|
||||
#include <clixon/clixon_plugin.h>
|
||||
|
|
|
|||
|
|
@ -46,11 +46,6 @@
|
|||
#define CLICON_LOG_STDOUT 4 /* print logs on stdout */
|
||||
#define CLICON_LOG_FILE 8 /* print logs on clicon_log_filename */
|
||||
|
||||
/*
|
||||
* Types
|
||||
*/
|
||||
typedef int (clicon_log_notify_t)(int level, char *msg, void *arg);
|
||||
|
||||
/*
|
||||
* Variables
|
||||
*/
|
||||
|
|
@ -64,7 +59,6 @@ int clicon_log_exit(void);
|
|||
int clicon_log_opt(char c);
|
||||
int clicon_log_file(char *filename);
|
||||
int clicon_get_logflags(void);
|
||||
int clicon_log_str(int level, char *msg);
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
int clicon_log(int level, char *format, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
int clicon_debug(int dbglevel, char *format, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
|
|
@ -72,9 +66,7 @@ int clicon_debug(int dbglevel, char *format, ...) __attribute__ ((format (printf
|
|||
int clicon_log(int level, char *format, ...);
|
||||
int clicon_debug(int dbglevel, char *format, ...);
|
||||
#endif
|
||||
clicon_log_notify_t *clicon_log_register_callback(clicon_log_notify_t *cb, void *arg);
|
||||
int clicon_debug_init(int dbglevel, FILE *f);
|
||||
|
||||
char *mon2name(int md);
|
||||
|
||||
#endif /* _CLIXON_LOG_H_ */
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ int clicon_msg_send(int s, struct clicon_msg *msg);
|
|||
|
||||
int clicon_msg_rcv(int s, struct clicon_msg **msg, int *eof);
|
||||
|
||||
int send_msg_notify(int s, int level, char *event);
|
||||
int send_msg_notify_xml(int s, cxobj *xev);
|
||||
|
||||
int send_msg_reply(int s, char *data, uint32_t datalen);
|
||||
|
||||
|
|
|
|||
|
|
@ -40,12 +40,12 @@
|
|||
* Types
|
||||
*/
|
||||
/* subscription callback */
|
||||
typedef int (*stream_fn_t)(clicon_handle, void *filter, void *arg);
|
||||
typedef stream_fn_t subscription_fn_t;
|
||||
typedef int (*stream_fn_t)(clicon_handle h, void *event, void *arg);
|
||||
|
||||
struct stream_subscription{
|
||||
struct stream_subscription *ss_next;
|
||||
char *ss_stream; /* Name of associated stream */
|
||||
char *ss_xpath; /* Filter selector as xpath */
|
||||
stream_fn_t ss_fn; /* Callback when event occurs */
|
||||
void *ss_arg; /* Callback argument */
|
||||
};
|
||||
|
|
@ -55,7 +55,7 @@ struct stream_subscription{
|
|||
struct event_stream{
|
||||
struct event_stream *es_next;
|
||||
char *es_name; /* name of notification event stream */
|
||||
char *es_description;
|
||||
char *es_description;
|
||||
struct stream_subscription *es_subscription;
|
||||
};
|
||||
typedef struct event_stream event_stream_t;
|
||||
|
|
@ -65,9 +65,15 @@ typedef struct event_stream event_stream_t;
|
|||
*/
|
||||
event_stream_t *stream_find(clicon_handle h, const char *name);
|
||||
int stream_register(clicon_handle h, const char *name, const char *description);
|
||||
int stream_free(event_stream_t *es);
|
||||
int stream_delete_all(event_stream_t *es);
|
||||
int stream_get_xml(clicon_handle h, int access, cbuf *cb);
|
||||
int stream_cb_add(clicon_handle h, char *stream, stream_fn_t fn, void *arg);
|
||||
int stream_cb_delete(clicon_handle h, char *stream, stream_fn_t fn);
|
||||
int stream_cb_add(clicon_handle h, char *stream, char *xpath, stream_fn_t fn, void *arg);
|
||||
int stream_cb_delete(clicon_handle h, char *stream, stream_fn_t fn, void *arg);
|
||||
int stream_notify_xml(clicon_handle h, char *stream, cxobj *xevent);
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
int stream_notify(clicon_handle h, char *stream, const char *event, ...) __attribute__ ((format (printf, 3, 4)));
|
||||
#else
|
||||
int stream_notify(clicon_handle h, char *stream, const char *event, ...);
|
||||
#endif
|
||||
|
||||
#endif /* _CLIXON_STREAM_H_ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue