debug.c revision 4b9d6701570cb98fd36e209314239d104ec584d3
/*
* Management of the debugging channels
*
* Copyright 2000 Alexandre Julliard
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
* Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Oracle elects to use only
* the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
* a choice of LGPL license versions is made available with the language indicating
* that LGPLv2 or any later version may be used, or where a choice of which version
* of the LGPL is applied is otherwise unspecified.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#define MAX_DEBUG_OPTIONS 256
static int nb_debug_options = -1;
static struct __wine_debug_functions funcs;
static void debug_init(void);
{
}
/* get the flags to use for a given channel, possibly setting them too in case of lazy init */
{
if (nb_debug_options)
{
sizeof(debug_options[0]), cmp_name );
}
/* no option for this channel */
return default_flags;
}
/* set the flags to use for a given channel; return 0 if the channel is not available to set */
{
if (nb_debug_options)
{
sizeof(debug_options[0]), cmp_name );
if (opt)
{
return 1;
}
}
return 0;
}
/* add a new debug option at the end of the option list */
{
if (!name[0]) /* "all" option */
{
return;
}
{
if (!res)
{
return;
}
}
if (nb_debug_options >= MAX_DEBUG_OPTIONS) return;
}
/* parse a set of debugging option specifications and add them to the option list */
static void parse_options( const char *str )
{
unsigned int i;
{
const char *p;
if (!p[0]) p = opt; /* assume it's a debug channel name */
if (p > opt)
{
for (i = 0; i < sizeof(debug_classes)/sizeof(debug_classes[0]); i++)
{
{
else clear |= 1 << i;
break;
}
}
continue;
}
else
{
if (*p == '-') clear = ~0;
else set = ~0;
}
if (*p == '+' || *p == '-') p++;
if (!p[0]) continue;
if (!strcmp( p, "all" ))
else
}
}
/* print the usage message */
static void debug_usage(void)
{
static const char usage[] =
"Syntax of the WINEDEBUG variable:\n"
" WINEDEBUG=[class]+xxx,[class]-yyy,...\n\n"
"Example: WINEDEBUG=+all,warn-heap\n"
" turns on all messages except warning heap messages\n"
"Available message classes: err, warn, fixme, trace\n";
exit(1);
}
/* initialize all options at startup */
static void debug_init(void)
{
char *wine_debug;
nb_debug_options = 0;
{
}
}
/* varargs wrapper for funcs.dbg_vprintf */
int wine_dbg_printf( const char *format, ... )
{
int ret;
return ret;
}
/* printf with temp buffer allocation */
const char *wine_dbg_sprintf( const char *format, ... )
{
static const int max_size = 200;
char *ret;
int len;
return ret;
}
/* varargs wrapper for funcs.dbg_vlog */
{
int ret;
return ret;
}
{
}
/* allocate some tmp string space */
/* FIXME: this is not 100% thread-safe */
{
static char *list[32];
static int pos;
char *ret;
int idx;
return ret;
}
/* release unused part of the buffer */
{
/* don't bother doing anything */
}
/* default implementation of wine_dbgstr_an */
static const char *default_dbgstr_an( const char *str, int n )
{
{
if (!str) return "(null)";
return res;
}
if (n < 0) n = 0;
*dst++ = '"';
{
unsigned char c = *str++;
switch (c)
{
default:
if (c >= ' ' && c <= 126)
*dst++ = c;
else
{
*dst++ = '\\';
*dst++ = 'x';
}
}
}
*dst++ = '"';
if (n > 0)
{
*dst++ = '.';
*dst++ = '.';
*dst++ = '.';
}
*dst++ = 0;
return res;
}
/* default implementation of wine_dbgstr_wn */
{
{
if (!str) return "(null)";
return res;
}
if (n == -1)
{
}
if (n < 0) n = 0;
*dst++ = 'L';
*dst++ = '"';
{
switch (c)
{
default:
if (c >= ' ' && c <= 126)
*dst++ = c;
else
{
*dst++ = '\\';
dst+=4;
}
}
}
*dst++ = '"';
if (n > 0)
{
*dst++ = '.';
*dst++ = '.';
*dst++ = '.';
}
*dst++ = 0;
return res;
}
/* default implementation of wine_dbg_vprintf */
{
}
/* default implementation of wine_dbg_vlog */
{
int ret = 0;
if (format)
return ret;
}
/* wrappers to use the function pointers */
const char *wine_dbgstr_an( const char * s, int n )
{
}
const char *wine_dbgstr_wn( const WCHAR *s, int n )
{
}
{
}
static struct __wine_debug_functions funcs =
{
};