diff options
| author | Martin Sustrik <sustrik@250bpm.com> | 2012-04-05 07:32:58 +0200 | 
|---|---|---|
| committer | Martin Sustrik <sustrik@250bpm.com> | 2012-04-05 07:32:58 +0200 | 
| commit | d82cbb3a81f116cd22e9895ecac36ac3d7b38929 (patch) | |
| tree | 03c923311b937f550bec325d131476513a02bebf /include | |
| parent | 52b8a917deb2990e7197b82e81e0258ebe30f424 (diff) | |
XS_PLUGIN and XS_FILTER implementation
This patch introduces following features:
- XS_PLUGIN context option to add plugins to libxs
- XS_FILTER option to switch between different filter types
- Automatic loading of plug-ins is *not* implemented.
From the implementation point of view:
- standard prefix filter is implemented as a pluggable filter
- trie_t and mtrie_t are joined into a single class
- the code for 0MQ/3.1 compatibility is left in in the form of comments
- new test for testing re-subscriptions is added
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/xs.h | 49 | 
1 files changed, 49 insertions, 0 deletions
| diff --git a/include/xs.h b/include/xs.h index 7e49df4..6f0004c 100644 --- a/include/xs.h +++ b/include/xs.h @@ -148,6 +148,7 @@ XS_EXPORT int xs_getmsgopt (xs_msg_t *msg, int option, void *optval,  #define XS_MAX_SOCKETS 1  #define XS_IO_THREADS 2 +#define XS_PLUGIN 3  XS_EXPORT void *xs_init ();  XS_EXPORT int xs_term (void *context); @@ -258,6 +259,54 @@ XS_EXPORT void *xs_stopwatch_start (void);  /*  the stopwatch was started.                                                */  XS_EXPORT unsigned long xs_stopwatch_stop (void *watch); +/******************************************************************************/ +/*  The API for pluggable filters.                                            */ +/*  THIS IS EXPERIMENTAL WORK AND MAY CHANGE WITHOUT PRIOR NOTICE.            */ +/******************************************************************************/ + +#define XS_FILTER 34 + +#define XS_PLUGIN_FILTER 1 + +#define XS_FILTER_ALL 0 +#define XS_FILTER_PREFIX 1 + +typedef struct +{ +    int type; +    int version; + +    int (*id) (void *core); +    void *(*pf_create) (void *core); +    void (*pf_destroy) (void *core, void *pf); +    int (*pf_subscribe) (void *core, void *pf, void *subscriber, +        const unsigned char *data, size_t size); +    int (*pf_unsubscribe) (void *core, void *pf, void *subscriber, +        const unsigned char *data, size_t size); +    void (*pf_unsubscribe_all) (void *core, void *pf, void *subscriber); +    void (*pf_match) (void *core, void *pf, +        const unsigned char *data, size_t size); + +    void *(*sf_create) (void *core); +    void (*sf_destroy) (void *core, void *sf); +    int (*sf_subscribe) (void *core, void *sf, +        const unsigned char *data, size_t size); +    int (*sf_unsubscribe) (void *core, void *sf, +        const unsigned char *data, size_t size); +    void (*sf_enumerate) (void *core, void *sf); +    int (*sf_match) (void *core, void *sf, +        const unsigned char *data, size_t size); + +} xs_filter_t; + +XS_EXPORT int xs_filter_subscribed (void *core, +    const unsigned char *data, size_t size); + +XS_EXPORT int xs_filter_unsubscribed (void *core, +    const unsigned char *data, size_t size); + +XS_EXPORT int xs_filter_matching (void *core, void *subscriber); +  #undef XS_EXPORT  #ifdef __cplusplus | 
