From 3cf080bb2dc0a03960d51e669a216891df621886 Mon Sep 17 00:00:00 2001 From: Jack Moffitt Date: Wed, 15 Jun 2005 05:37:24 +0000 Subject: [PATCH] Add library init and shutdown. --- examples/active.c | 6 ++++++ examples/basic.c | 5 +++++ examples/roster.c | 6 ++++++ src/ctx.c | 12 ++++++++++++ strophe.h | 5 +++++ 5 files changed, 34 insertions(+) diff --git a/examples/active.c b/examples/active.c index 8a9aa55..9a7dc2b 100644 --- a/examples/active.c +++ b/examples/active.c @@ -98,6 +98,9 @@ int main(int argc, char **argv) return 1; } + /* initialize lib */ + xmpp_initialize(); + /* create a context */ ctx = xmpp_ctx_new(NULL, NULL); @@ -118,5 +121,8 @@ int main(int argc, char **argv) xmpp_conn_release(conn); xmpp_ctx_free(ctx); + /* shutdown lib */ + xmpp_shutdown(); + return 0; } diff --git a/examples/basic.c b/examples/basic.c index f8b8d8d..619d766 100644 --- a/examples/basic.c +++ b/examples/basic.c @@ -42,6 +42,9 @@ int main(int argc, char **argv) return 1; } + /* init library */ + xmpp_initialize(); + /* create a context */ ctx = xmpp_ctx_new(NULL, NULL); @@ -62,5 +65,7 @@ int main(int argc, char **argv) xmpp_conn_release(conn); xmpp_ctx_free(ctx); + xmpp_shutdown(); + return 0; } diff --git a/examples/roster.c b/examples/roster.c index 7bbe040..1e3dc91 100644 --- a/examples/roster.c +++ b/examples/roster.c @@ -103,6 +103,9 @@ int main(int argc, char **argv) return 1; } + /* initialize lib */ + xmpp_initialize(); + /* create a context */ ctx = xmpp_ctx_new(NULL, NULL); @@ -123,5 +126,8 @@ int main(int argc, char **argv) xmpp_conn_release(conn); xmpp_ctx_free(ctx); + /* shutdown lib */ + xmpp_shutdown(); + return 0; } diff --git a/src/ctx.c b/src/ctx.c index ad3e6c4..623aa1d 100644 --- a/src/ctx.c +++ b/src/ctx.c @@ -25,6 +25,18 @@ #define vsnprintf _vsnprintf #endif +/* initialization and shutdown */ + +void xmpp_initialize(void) +{ + sock_initialize(); +} + +void xmpp_shutdown(void) +{ + sock_shutdown(); +} + /** version **/ /* TODO: update from the build system? */ diff --git a/strophe.h b/strophe.h index a813ea7..1e14089 100644 --- a/strophe.h +++ b/strophe.h @@ -22,6 +22,11 @@ #define XMPP_NS_DISCO_ITEMS "http://jabber.org/protocol/disco#items" #define XMPP_NS_ROSTER "jabber:iq:roster" +/** initialization and shutdown **/ + +void xmpp_initialize(void); +void xmpp_shutdown(void); + /** version **/ int xmpp_version_check(int major, int minor);