From 506b66018f6bd0eda3b7d31e1ac22bcb4fbd0720 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 4 Jan 2013 17:37:49 +0100 Subject: [PATCH] only export one symbol from the lib, containing a struct with all functions. useful for using ustream-ssl as a plugin Signed-off-by: Felix Fietkau --- ustream-ssl.c | 18 +++++++++++++----- ustream-ssl.h | 20 +++++++++++++++----- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/ustream-ssl.c b/ustream-ssl.c index 6a337be..471e29c 100644 --- a/ustream-ssl.c +++ b/ustream-ssl.c @@ -180,7 +180,7 @@ static void ustream_ssl_stream_init(struct ustream_ssl *us) ustream_init_defaults(s); } -void *ustream_ssl_context_new(bool server) +static void *_ustream_ssl_context_new(bool server) { #ifdef CYASSL_OPENSSL_H_ SSL_METHOD *m; @@ -213,7 +213,7 @@ void *ustream_ssl_context_new(bool server) return c; } -int ustream_ssl_context_set_crt_file(void *ctx, const char *file) +static int _ustream_ssl_context_set_crt_file(void *ctx, const char *file) { int ret; @@ -224,7 +224,7 @@ int ustream_ssl_context_set_crt_file(void *ctx, const char *file) return ret; } -int ustream_ssl_context_set_key_file(void *ctx, const char *file) +static int _ustream_ssl_context_set_key_file(void *ctx, const char *file) { int ret; @@ -235,12 +235,12 @@ int ustream_ssl_context_set_key_file(void *ctx, const char *file) return ret; } -void ustream_ssl_context_free(void *ctx) +static void _ustream_ssl_context_free(void *ctx) { SSL_CTX_free(ctx); } -int ustream_ssl_init(struct ustream_ssl *us, struct ustream *conn, void *ctx, bool server) +static int _ustream_ssl_init(struct ustream_ssl *us, struct ustream *conn, void *ctx, bool server) { us->error_timer.cb = ustream_ssl_error_cb; us->server = server; @@ -257,3 +257,11 @@ int ustream_ssl_init(struct ustream_ssl *us, struct ustream *conn, void *ctx, bo return 0; } + +const struct ustream_ssl_ops ustream_ssl_ops = { + .context_new = _ustream_ssl_context_new, + .context_set_crt_file = _ustream_ssl_context_set_crt_file, + .context_set_key_file = _ustream_ssl_context_set_key_file, + .context_free = _ustream_ssl_context_free, + .init = _ustream_ssl_init, +}; diff --git a/ustream-ssl.h b/ustream-ssl.h index 5148843..5cc4d15 100644 --- a/ustream-ssl.h +++ b/ustream-ssl.h @@ -17,11 +17,21 @@ struct ustream_ssl { bool server; }; -void *ustream_ssl_context_new(bool server); -int ustream_ssl_context_set_crt_file(void *ctx, const char *file); -int ustream_ssl_context_set_key_file(void *ctx, const char *file); -void ustream_ssl_context_free(void *ctx); +struct ustream_ssl_ops { + void *(*context_new)(bool server); + int (*context_set_crt_file)(void *ctx, const char *file); + int (*context_set_key_file)(void *ctx, const char *file); + void (*context_free)(void *ctx); -int ustream_ssl_init(struct ustream_ssl *us, struct ustream *conn, void *ctx, bool server); + int (*init)(struct ustream_ssl *us, struct ustream *conn, void *ctx, bool server); +}; + +extern const struct ustream_ssl_ops ustream_ssl_ops; + +#define ustream_ssl_context_new ustream_ssl_ops.context_new +#define ustream_ssl_context_set_crt_file ustream_ssl_ops.context_set_crt_file +#define ustream_ssl_context_set_key_file ustream_ssl_ops.context_set_key_file +#define ustream_ssl_context_free ustream_ssl_ops.context_free +#define ustream_ssl_init ustream_ssl_ops.init #endif -- 2.30.2