From afe2f28e65f3c3d9b510f101d6cd76c59794cd17 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Mon, 22 Oct 2012 02:32:53 +0200 Subject: [PATCH] Doxygen: Explain init/shutdown, add small example. --- backend.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/backend.c b/backend.c index 9f0f119f..389df253 100644 --- a/backend.c +++ b/backend.c @@ -74,6 +74,42 @@ * * Initializing and shutting down libsigrok. * + * Before using any of the libsigrok functionality, sr_init() must + * be called to initialize the library, which will return a struct sr_context + * when the initialization was successful. + * + * When libsigrok functionality is no longer needed, sr_exit() should be + * called, which will (among other things) free the struct sr_context. + * + * Example for a minimal program using libsigrok: + * + * @code{.c} + * #include + * #include + * + * int main(int argc, char **argv) + * { + * int ret; + * struct sr_context *sr_ctx; + * + * if ((ret = sr_init(&sr_ctx)) != SR_OK) { + * printf("Error initializing libsigrok (%s): %s.", + * sr_strerror_name(ret), sr_strerror(ret)); + * return 1; + * } + * + * // Use libsigrok functions here... + * + * if ((ret = sr_exit(sr_ctx)) != SR_OK) { + * printf("Error shutting down libsigrok (%s): %s.", + * sr_strerror_name(ret), sr_strerror(ret)); + * return 1; + * } + * + * return 0; + * } + * @endcode + * * @{ */