diff options
author | defanor <defanor@uberspace.net> | 2020-05-09 12:17:45 +0300 |
---|---|---|
committer | defanor <defanor@uberspace.net> | 2020-05-09 12:17:45 +0300 |
commit | 97a1943d41d0bf067ddd3b6a465ba447d41923de (patch) | |
tree | 87cc7fbc01724478f1bc49ab1542611b295885a4 /src | |
parent | a94e340cc77152535383d53dbbaecd5076201a1c (diff) |
Wrap the SASL property callback
So that a library user's SASL property callback gets a pointer to the
whole rexmpp structure at once, similarly to other callbacks.
Diffstat (limited to 'src')
-rw-r--r-- | src/rexmpp.c | 11 | ||||
-rw-r--r-- | src/rexmpp.h | 2 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/rexmpp.c b/src/rexmpp.c index 2e05cbb..c74b92b 100644 --- a/src/rexmpp.c +++ b/src/rexmpp.c @@ -201,6 +201,14 @@ xmlNodePtr rexmpp_xml_default_disco_info () { return identity; } +int rexmpp_sasl_cb (Gsasl *ctx, Gsasl_session *sctx, Gsasl_property prop) { + rexmpp_t *s = gsasl_callback_hook_get(ctx); + if (s == NULL) { + return GSASL_NO_CALLBACK; + } + return s->sasl_property_cb(s, prop); +} + rexmpp_err_t rexmpp_init (rexmpp_t *s, const char *jid, log_function_t log_function, @@ -322,7 +330,8 @@ rexmpp_err_t rexmpp_init (rexmpp_t *s, xmlFreeParserCtxt(s->xml_parser); return REXMPP_E_SASL; } - gsasl_callback_set(s->sasl_ctx, s->sasl_property_cb); + gsasl_callback_hook_set(s->sasl_ctx, s); + gsasl_callback_set(s->sasl_ctx, rexmpp_sasl_cb); s->disco_info = rexmpp_xml_default_disco_info(); diff --git a/src/rexmpp.h b/src/rexmpp.h index 97592f7..cb650a3 100644 --- a/src/rexmpp.h +++ b/src/rexmpp.h @@ -199,7 +199,7 @@ enum rexmpp_err { typedef enum rexmpp_err rexmpp_err_t; typedef void (*log_function_t) (rexmpp_t *s, int priority, const char *format, va_list args); -typedef int (*sasl_property_cb_t) (Gsasl *ctx, Gsasl_session *sctx, Gsasl_property prop); +typedef int (*sasl_property_cb_t) (rexmpp_t *s, Gsasl_property prop); typedef int (*xml_in_cb_t) (rexmpp_t *s, xmlNodePtr node); typedef int (*xml_out_cb_t) (rexmpp_t *s, xmlNodePtr node); |