2001-10-04 Lutz M�ller <urc8@rz.uni-karlsruhe.de>
* libgphoto2/debug.c: Move debugging stuff to libgphoto2_port so
that those messages get saved, too.
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@2378 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
2001-10-04 Lutz Müller <urc8@rz.uni-karlsruhe.de>
|
||||
|
||||
* libgphoto2/debug.c: Move debugging stuff to libgphoto2_port so
|
||||
that those messages get saved, too.
|
||||
|
||||
2001-10-04 Lutz Müller <urc8@rz.uni-karlsruhe.de>
|
||||
|
||||
* camlibs/konica/library.c: const
|
||||
|
||||
@@ -26,20 +26,27 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <gphoto2-result.h>
|
||||
#include <gphoto2-port-debug.h>
|
||||
|
||||
static int glob_debug = GP_DEBUG_NONE;
|
||||
|
||||
static GPDebugFunc debug_func = NULL;
|
||||
static void *debug_func_data = NULL;
|
||||
|
||||
static unsigned int debug_history_size = 0;
|
||||
static char *debug_history = NULL;
|
||||
static void
|
||||
gp_port_func (const char *msg, void *data)
|
||||
{
|
||||
if (debug_func)
|
||||
debug_func ("port", msg, data);
|
||||
}
|
||||
|
||||
void
|
||||
gp_debug_set_func (GPDebugFunc func, void *data)
|
||||
{
|
||||
debug_func = func;
|
||||
debug_func_data = data;
|
||||
|
||||
gp_port_debug_set_func (gp_port_func, data);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -47,35 +54,12 @@ gp_debug_printf (int level, const char *id, const char *format, ...)
|
||||
{
|
||||
char buffer[2048];
|
||||
va_list arg;
|
||||
int i;
|
||||
|
||||
va_start (arg, format);
|
||||
vsprintf (buffer, format, arg);
|
||||
va_end (arg);
|
||||
|
||||
/* Create history if needed */
|
||||
if (!debug_history) {
|
||||
debug_history_size = 1024;
|
||||
debug_history = malloc (sizeof (char) * debug_history_size);
|
||||
memset (debug_history, 0, debug_history_size);
|
||||
}
|
||||
|
||||
/* Do we have to forget parts of the debug history? */
|
||||
while (debug_history_size - strlen (debug_history) <
|
||||
strlen (buffer) + 1) {
|
||||
|
||||
/* Determine len of first entry */
|
||||
for (i = 0; debug_history[i] != '\0'; i++)
|
||||
if (debug_history[i] == '\n')
|
||||
break;
|
||||
|
||||
/* Remove the first entry */
|
||||
memmove (debug_history, debug_history + i + 1,
|
||||
strlen (debug_history) - i);
|
||||
}
|
||||
|
||||
strcat (debug_history, buffer);
|
||||
strcat (debug_history, "\n");
|
||||
gp_port_debug_history_append (buffer);
|
||||
|
||||
if (glob_debug == GP_DEBUG_NONE)
|
||||
return;
|
||||
@@ -84,9 +68,6 @@ gp_debug_printf (int level, const char *id, const char *format, ...)
|
||||
if (debug_func) {
|
||||
|
||||
/* Custom debug function */
|
||||
va_start (arg, format);
|
||||
vsprintf (buffer, format, arg);
|
||||
va_end (arg);
|
||||
debug_func (id, buffer, debug_func_data);
|
||||
|
||||
} else {
|
||||
@@ -119,23 +100,13 @@ gp_debug_get_level (void)
|
||||
const char *
|
||||
gp_debug_history_get (void)
|
||||
{
|
||||
return (debug_history);
|
||||
return (gp_port_debug_history_get ());
|
||||
}
|
||||
|
||||
int
|
||||
gp_debug_history_set_size (unsigned int size)
|
||||
{
|
||||
char *new_debug_history;
|
||||
|
||||
new_debug_history = realloc (debug_history, sizeof (char) * size);
|
||||
|
||||
if (!new_debug_history)
|
||||
return (GP_ERROR_NO_MEMORY);
|
||||
|
||||
debug_history_size = size;
|
||||
debug_history = new_debug_history;
|
||||
|
||||
return (GP_OK);
|
||||
return (gp_port_debug_history_set_size (size));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user