From 31c58d33a6dcd5cefc27bbc4fb14f477be80ca9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Fillod=2C=20F8CFE?= Date: Mon, 16 Jan 2006 21:00:25 +0000 Subject: [PATCH] added rig_set_debug_callback example in documentation git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2063 7ae35d74-ebe9-4afe-98af-79ac388436b8 --- src/debug.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/debug.c b/src/debug.c index a7c5ffe40..c0b7ce7a9 100644 --- a/src/debug.c +++ b/src/debug.c @@ -2,7 +2,7 @@ * Hamlib Interface - debug * Copyright (c) 2000-2005 by Stephane Fillod * - * $Id: debug.c,v 1.1 2005-04-09 09:49:12 fillods Exp $ + * $Id: debug.c,v 1.2 2006-01-16 21:00:25 fillods Exp $ * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as @@ -141,6 +141,28 @@ void HAMLIB_API rig_debug(enum rig_debug_level_e debug_level, const char *fmt, . * \param arg A Pointer to some private data to pass later on to the callback * * Install a callback for \a rig_debug messages. +\code +int +rig_message_cb (enum rig_debug_level_e debug_level, + rig_ptr_t user_data, + const char *fmt, + va_list ap) +{ + char buf[1024]; + + sprintf (buf, "Message(%s) ", (char*)user_data); + syslog (LOG_USER, buf); + vsprintf (buf, fmt, ap); + syslog (LOG_USER, buf); + + return RIG_OK; +} + + . . . + + char *cookie = "Foo"; + rig_set_debug_callback (rig_message_cb, (rig_ptr_t)cookie); +\endcode * * \return RIG_OK if the operation has been sucessful, otherwise * a negative value if an error occured (in which case, cause @@ -148,7 +170,6 @@ void HAMLIB_API rig_debug(enum rig_debug_level_e debug_level, const char *fmt, . * * \sa rig_debug() */ -//typedef int (*vprintf_cb_t) (enum rig_debug_level_e debug_level, rig_ptr_t, const char *, va_list); vprintf_cb_t rig_set_debug_callback(vprintf_cb_t cb, rig_ptr_t arg) { vprintf_cb_t prev_cb = rig_vprintf_cb;