added a configure option to enable the Vstr string library even if register_printf_function is available
This commit is contained in:
+16
-2
@@ -712,6 +712,14 @@ AC_ARG_ENABLE(
|
|||||||
fi]
|
fi]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(
|
||||||
|
[vstr],
|
||||||
|
AS_HELP_STRING([--enable-vstr],[enforce using the Vstr string library to replace glibc-like printf hooks (default is NO).]),
|
||||||
|
[if test x$enableval = xyes; then
|
||||||
|
vstr=true
|
||||||
|
fi]
|
||||||
|
)
|
||||||
|
|
||||||
dnl =========================
|
dnl =========================
|
||||||
dnl set up compiler and flags
|
dnl set up compiler and flags
|
||||||
dnl =========================
|
dnl =========================
|
||||||
@@ -844,8 +852,14 @@ AC_CHECK_FUNC(
|
|||||||
[AC_DEFINE(HAVE_PRINTF_HOOKS)],
|
[AC_DEFINE(HAVE_PRINTF_HOOKS)],
|
||||||
[
|
[
|
||||||
AC_MSG_NOTICE([printf does not support custom format specifiers!])
|
AC_MSG_NOTICE([printf does not support custom format specifiers!])
|
||||||
AC_HAVE_LIBRARY([vstr],[LIBS="$LIBS"]; vstr=true,[AC_MSG_ERROR([Vstr string library not found])])
|
vstr=true
|
||||||
])
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
if test x$vstr = xtrue; then
|
||||||
|
AC_HAVE_LIBRARY([vstr],[LIBS="$LIBS"],[AC_MSG_ERROR([Vstr string library not found])])
|
||||||
|
AC_DEFINE(USE_VSTR)
|
||||||
|
fi
|
||||||
|
|
||||||
if test x$gmp = xtrue; then
|
if test x$gmp = xtrue; then
|
||||||
AC_HAVE_LIBRARY([gmp],[LIBS="$LIBS"],[AC_MSG_ERROR([GNU Multi Precision library gmp not found])])
|
AC_HAVE_LIBRARY([gmp],[LIBS="$LIBS"],[AC_MSG_ERROR([GNU Multi Precision library gmp not found])])
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ struct printf_hook_handler_t {
|
|||||||
*/
|
*/
|
||||||
int argtypes[ARGS_MAX];
|
int argtypes[ARGS_MAX];
|
||||||
|
|
||||||
#ifndef HAVE_PRINTF_HOOKS
|
#ifdef USE_VSTR
|
||||||
/**
|
/**
|
||||||
* name required for Vstr
|
* name required for Vstr
|
||||||
*/
|
*/
|
||||||
@@ -75,7 +75,7 @@ static printf_hook_handler_t *printf_hooks[NUM_HANDLERS];
|
|||||||
#define SPEC_TO_INDEX(spec) ((int)(spec) - (int)'A')
|
#define SPEC_TO_INDEX(spec) ((int)(spec) - (int)'A')
|
||||||
#define IS_VALID_SPEC(spec) (SPEC_TO_INDEX(spec) > -1 && SPEC_TO_INDEX(spec) < NUM_HANDLERS)
|
#define IS_VALID_SPEC(spec) (SPEC_TO_INDEX(spec) > -1 && SPEC_TO_INDEX(spec) < NUM_HANDLERS)
|
||||||
|
|
||||||
#ifdef HAVE_PRINTF_HOOKS
|
#if defined(HAVE_PRINTF_HOOKS) && !defined(USE_VSTR)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Printf hook print function. This is actually of type "printf_function",
|
* Printf hook print function. This is actually of type "printf_function",
|
||||||
@@ -359,7 +359,7 @@ static void add_handler(private_printf_hook_t *this, char spec,
|
|||||||
|
|
||||||
if (handler->numargs > 0)
|
if (handler->numargs > 0)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_PRINTF_HOOKS
|
#if defined(HAVE_PRINTF_HOOKS) && !defined(USE_VSTR)
|
||||||
register_printf_function(spec, custom_print, custom_arginfo);
|
register_printf_function(spec, custom_print, custom_arginfo);
|
||||||
#else
|
#else
|
||||||
Vstr_conf *conf = get_vstr_conf();
|
Vstr_conf *conf = get_vstr_conf();
|
||||||
@@ -382,7 +382,7 @@ static void add_handler(private_printf_hook_t *this, char spec,
|
|||||||
static void destroy(private_printf_hook_t *this)
|
static void destroy(private_printf_hook_t *this)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
#ifndef HAVE_PRINTF_HOOKS
|
#ifdef USE_VSTR
|
||||||
Vstr_conf *conf = get_vstr_conf();
|
Vstr_conf *conf = get_vstr_conf();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -391,7 +391,7 @@ static void destroy(private_printf_hook_t *this)
|
|||||||
printf_hook_handler_t *handler = printf_hooks[i];
|
printf_hook_handler_t *handler = printf_hooks[i];
|
||||||
if (handler)
|
if (handler)
|
||||||
{
|
{
|
||||||
#ifndef HAVE_PRINTF_HOOKS
|
#ifdef USE_VSTR
|
||||||
vstr_fmt_del(conf, handler->name);
|
vstr_fmt_del(conf, handler->name);
|
||||||
free(handler->name);
|
free(handler->name);
|
||||||
#endif
|
#endif
|
||||||
@@ -399,7 +399,7 @@ static void destroy(private_printf_hook_t *this)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_PRINTF_HOOKS
|
#ifdef USE_VSTR
|
||||||
/* freeing the Vstr_conf of the main thread */
|
/* freeing the Vstr_conf of the main thread */
|
||||||
pthread_key_delete(vstr_conf_key);
|
pthread_key_delete(vstr_conf_key);
|
||||||
vstr_free_conf(conf);
|
vstr_free_conf(conf);
|
||||||
@@ -420,7 +420,7 @@ printf_hook_t *printf_hook_create()
|
|||||||
|
|
||||||
memset(printf_hooks, 0, sizeof(printf_hooks));
|
memset(printf_hooks, 0, sizeof(printf_hooks));
|
||||||
|
|
||||||
#ifndef HAVE_PRINTF_HOOKS
|
#ifdef USE_VSTR
|
||||||
if (!vstr_init())
|
if (!vstr_init())
|
||||||
{
|
{
|
||||||
DBG1("failed to initialize Vstr library!");
|
DBG1("failed to initialize Vstr library!");
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ typedef struct printf_hook_t printf_hook_t;
|
|||||||
typedef struct printf_hook_spec_t printf_hook_spec_t;
|
typedef struct printf_hook_spec_t printf_hook_spec_t;
|
||||||
typedef enum printf_hook_argtype_t printf_hook_argtype_t;
|
typedef enum printf_hook_argtype_t printf_hook_argtype_t;
|
||||||
|
|
||||||
#ifdef HAVE_PRINTF_HOOKS
|
#if defined(HAVE_PRINTF_HOOKS) && !defined(USE_VSTR)
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <printf.h>
|
#include <printf.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user