Skip to content

Commit a2b3b6b

Browse files
committed
Add xmpp_tlscert_get_userdata()
This fixes #249 Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
1 parent dfb3e86 commit a2b3b6b

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
/** handlers **/
3333
#if (__STDC_VERSION__ >= 202000L)
34-
typedef void* xmpp_void_handler;
34+
typedef void *xmpp_void_handler;
3535
#else
3636
typedef int (*xmpp_void_handler)();
3737
#endif

src/tls.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,23 @@ xmpp_conn_t *xmpp_tlscert_get_conn(const xmpp_tlscert_t *cert)
7474
return cert->conn;
7575
}
7676

77+
/** Get the userdata of a Strophe connection which is assigned to this
78+
* certificate.
79+
*
80+
* @param cert a Strophe TLS certificate object
81+
*
82+
* @return the userdata of a Strophe connection object where this certificate
83+
* originates from
84+
*
85+
* @ingroup TLS
86+
*/
87+
void *xmpp_tlscert_get_userdata(const xmpp_tlscert_t *cert)
88+
{
89+
if (cert->conn == NULL)
90+
return NULL;
91+
return cert->conn->userdata;
92+
}
93+
7794
/** Get the complete PEM of this certificate.
7895
*
7996
* @param cert a Strophe TLS certificate object

strophe.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ void xmpp_ctx_set_timeout(xmpp_ctx_t *ctx, unsigned long timeout);
642642

643643
xmpp_ctx_t *xmpp_tlscert_get_ctx(const xmpp_tlscert_t *cert);
644644
xmpp_conn_t *xmpp_tlscert_get_conn(const xmpp_tlscert_t *cert);
645+
void *xmpp_tlscert_get_userdata(const xmpp_tlscert_t *cert);
645646
const char *xmpp_tlscert_get_pem(const xmpp_tlscert_t *cert);
646647
const char *xmpp_tlscert_get_dnsname(const xmpp_tlscert_t *cert, size_t n);
647648
const char *xmpp_tlscert_get_string(const xmpp_tlscert_t *cert,

0 commit comments

Comments
 (0)