core: Remove old debug helper function
* src/debug.c (_gpgme_debug): Remove. (_gpgme_debugf): Rename to _gpgme_debug. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
5857491a2a
commit
94d274a1a3
@ -54,7 +54,7 @@ _gpgme_assuan_log_cb (assuan_context_t ctx, void *hook,
|
|||||||
if (msg == NULL)
|
if (msg == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
_gpgme_debug (DEBUG_ASSUAN, "%s", msg);
|
_gpgme_debug (DEBUG_ASSUAN, -1, NULL, NULL, NULL, "%s", msg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
66
src/debug.c
66
src/debug.c
@ -205,12 +205,13 @@ debug_init (void)
|
|||||||
|
|
||||||
if (debug_level > 0)
|
if (debug_level > 0)
|
||||||
{
|
{
|
||||||
_gpgme_debug (DEBUG_INIT, "gpgme_debug: level=%d\n", debug_level);
|
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL,
|
||||||
|
"gpgme_debug: level=%d\n", debug_level);
|
||||||
#ifdef HAVE_W32_SYSTEM
|
#ifdef HAVE_W32_SYSTEM
|
||||||
{
|
{
|
||||||
const char *name = _gpgme_get_inst_dir ();
|
const char *name = _gpgme_get_inst_dir ();
|
||||||
_gpgme_debug (DEBUG_INIT, "gpgme_debug: gpgme='%s'\n",
|
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL,
|
||||||
name? name: "?");
|
"gpgme_debug: gpgme='%s'\n", name? name: "?");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -230,58 +231,6 @@ _gpgme_debug_subsystem_init (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Log the formatted string FORMAT at debug level LEVEL or higher.
|
|
||||||
*
|
|
||||||
* Returns: 0
|
|
||||||
*
|
|
||||||
* Note that we always return 0 because the old TRACE macro evaluated
|
|
||||||
* to 0 which issues a warning with newer gcc version about an unused
|
|
||||||
* values. By using a return value of this function this can be
|
|
||||||
* avoided. Fixme: It might be useful to check whether the return
|
|
||||||
* value from the TRACE macros are actually used somewhere.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
_gpgme_debug (int level, const char *format, ...)
|
|
||||||
{
|
|
||||||
va_list arg_ptr;
|
|
||||||
int saved_errno;
|
|
||||||
|
|
||||||
saved_errno = errno;
|
|
||||||
if (debug_level < level)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
va_start (arg_ptr, format);
|
|
||||||
LOCK (debug_lock);
|
|
||||||
{
|
|
||||||
struct tm *tp;
|
|
||||||
time_t atime = time (NULL);
|
|
||||||
|
|
||||||
tp = localtime (&atime);
|
|
||||||
fprintf (errfp, "GPGME %04d-%02d-%02d %02d:%02d:%02d <0x%04llx> ",
|
|
||||||
1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday,
|
|
||||||
tp->tm_hour, tp->tm_min, tp->tm_sec,
|
|
||||||
(unsigned long long) ath_self ());
|
|
||||||
}
|
|
||||||
#ifdef FRAME_NR
|
|
||||||
{
|
|
||||||
int indent;
|
|
||||||
|
|
||||||
indent = frame_nr > 0? (2 * (frame_nr - 1)):0;
|
|
||||||
fprintf (errfp, "%*s", indent < 40? indent : 40, "");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
vfprintf (errfp, format, arg_ptr);
|
|
||||||
va_end (arg_ptr);
|
|
||||||
if(format && *format && format[strlen (format) - 1] != '\n')
|
|
||||||
putc ('\n', errfp);
|
|
||||||
UNLOCK (debug_lock);
|
|
||||||
fflush (errfp);
|
|
||||||
|
|
||||||
gpg_err_set_errno (saved_errno);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Log the formatted string FORMAT prefixed with additional info
|
/* Log the formatted string FORMAT prefixed with additional info
|
||||||
* depending on MODE:
|
* depending on MODE:
|
||||||
*
|
*
|
||||||
@ -300,7 +249,7 @@ _gpgme_debug (int level, const char *format, ...)
|
|||||||
* value from the TRACE macros are actually used somewhere.
|
* value from the TRACE macros are actually used somewhere.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
_gpgme_debugf (int level, int mode, const char *func, const char *tagname,
|
_gpgme_debug (int level, int mode, const char *func, const char *tagname,
|
||||||
const char *tagvalue, const char *format, ...)
|
const char *tagvalue, const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list arg_ptr;
|
va_list arg_ptr;
|
||||||
@ -367,7 +316,6 @@ _gpgme_debugf (int level, int mode, const char *func, const char *tagname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Start a new debug line in *LINE, logged at level LEVEL or higher,
|
/* Start a new debug line in *LINE, logged at level LEVEL or higher,
|
||||||
and starting with the formatted string FORMAT. */
|
and starting with the formatted string FORMAT. */
|
||||||
void
|
void
|
||||||
@ -431,7 +379,7 @@ _gpgme_debug_end (void **line)
|
|||||||
|
|
||||||
/* The smallest possible level is 1, so force logging here by
|
/* The smallest possible level is 1, so force logging here by
|
||||||
using that. */
|
using that. */
|
||||||
_gpgme_debug (1, "%s", *line);
|
_gpgme_debug (1, -1, NULL, NULL, NULL, "%s", *line);
|
||||||
gpgrt_free (*line);
|
gpgrt_free (*line);
|
||||||
*line = NULL;
|
*line = NULL;
|
||||||
}
|
}
|
||||||
@ -480,6 +428,6 @@ _gpgme_debug_buffer (int lvl, const char *const fmt,
|
|||||||
*(strp++) = ' ';
|
*(strp++) = ' ';
|
||||||
*(strp2) = '\0';
|
*(strp2) = '\0';
|
||||||
|
|
||||||
_gpgme_debug (lvl, fmt, func, str);
|
_gpgme_debug (lvl, -1, NULL, NULL, NULL, fmt, func, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
26
src/debug.h
26
src/debug.h
@ -68,8 +68,7 @@ int _gpgme_debug_set_debug_envvar (const char *value);
|
|||||||
void _gpgme_debug_subsystem_init (void);
|
void _gpgme_debug_subsystem_init (void);
|
||||||
|
|
||||||
/* Log the formatted string FORMAT at debug level LEVEL or higher. */
|
/* Log the formatted string FORMAT at debug level LEVEL or higher. */
|
||||||
int _gpgme_debug (int level, const char *format, ...);
|
int _gpgme_debug (int level, int mode,
|
||||||
int _gpgme_debugf (int level, int mode,
|
|
||||||
const char *func, const char *tagname, const char *tagvalue,
|
const char *func, const char *tagname, const char *tagvalue,
|
||||||
const char *format, ...) GPGRT_ATTR_PRINTF(6,7);
|
const char *format, ...) GPGRT_ATTR_PRINTF(6,7);
|
||||||
|
|
||||||
@ -95,7 +94,8 @@ int _gpgme_debug_frame_end (void);
|
|||||||
static inline gpgme_error_t
|
static inline gpgme_error_t
|
||||||
_gpgme_trace_gpgme_error (gpgme_error_t err, const char *file, int line)
|
_gpgme_trace_gpgme_error (gpgme_error_t err, const char *file, int line)
|
||||||
{
|
{
|
||||||
_gpgme_debug (DEBUG_ENGINE, "%s:%d: returning error: %s\n",
|
_gpgme_debug (DEBUG_ENGINE, -1, NULL, NULL, NULL,
|
||||||
|
"%s:%d: returning error: %s\n",
|
||||||
_gpgme_debug_srcname (file), line, gpgme_strerror (err));
|
_gpgme_debug_srcname (file), line, gpgme_strerror (err));
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -115,20 +115,21 @@ _gpgme_trace_gpgme_error (gpgme_error_t err, const char *file, int line)
|
|||||||
|
|
||||||
#define TRACE_BEG(lvl, name, tag, ...) \
|
#define TRACE_BEG(lvl, name, tag, ...) \
|
||||||
_TRACE (lvl, name, tag); \
|
_TRACE (lvl, name, tag); \
|
||||||
_gpgme_debugf (_gpgme_trace_level, 1, \
|
_gpgme_debug (_gpgme_trace_level, 1, \
|
||||||
_gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \
|
_gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \
|
||||||
__VA_ARGS__)
|
__VA_ARGS__)
|
||||||
|
|
||||||
#define TRACE(lvl, name, tag, ...) \
|
#define TRACE(lvl, name, tag, ...) \
|
||||||
_gpgme_debug_frame_begin (), \
|
_gpgme_debug_frame_begin (), \
|
||||||
_gpgme_debugf (lvl, 0, \
|
_gpgme_debug (lvl, 0, \
|
||||||
name, STRINGIFY (tag), (void *) (uintptr_t) tag, \
|
name, STRINGIFY (tag), (void *) (uintptr_t) tag, \
|
||||||
__VA_ARGS__), \
|
__VA_ARGS__), \
|
||||||
_gpgme_debug_frame_end ()
|
_gpgme_debug_frame_end ()
|
||||||
|
|
||||||
#define TRACE_ERR(err) \
|
#define TRACE_ERR(err) \
|
||||||
err == 0 ? (TRACE_SUC ("")) : \
|
err == 0 ? (TRACE_SUC ("")) : \
|
||||||
(_gpgme_debug (_gpgme_trace_level, "%s:%d: error: %s <%s>\n", \
|
(_gpgme_debug (_gpgme_trace_level, -1, NULL, NULL, NULL, \
|
||||||
|
"%s:%d: error: %s <%s>\n", \
|
||||||
_gpgme_trace_func, __LINE__, gpgme_strerror (err), \
|
_gpgme_trace_func, __LINE__, gpgme_strerror (err), \
|
||||||
gpgme_strsource (err)), _gpgme_debug_frame_end (), (err))
|
gpgme_strsource (err)), _gpgme_debug_frame_end (), (err))
|
||||||
|
|
||||||
@ -136,26 +137,29 @@ _gpgme_trace_gpgme_error (gpgme_error_t err, const char *file, int line)
|
|||||||
/* The cast to void suppresses GCC warnings. */
|
/* The cast to void suppresses GCC warnings. */
|
||||||
#define TRACE_SYSRES(res) \
|
#define TRACE_SYSRES(res) \
|
||||||
res >= 0 ? ((void) (TRACE_SUC ("result=%i", res)), (res)) : \
|
res >= 0 ? ((void) (TRACE_SUC ("result=%i", res)), (res)) : \
|
||||||
(_gpgme_debug (_gpgme_trace_level, "%s: error: %s\n", \
|
(_gpgme_debug (_gpgme_trace_level, -1, NULL, NULL, NULL, \
|
||||||
|
"%s: error: %s\n", \
|
||||||
_gpgme_trace_func, strerror (errno)), \
|
_gpgme_trace_func, strerror (errno)), \
|
||||||
_gpgme_debug_frame_end (), (res))
|
_gpgme_debug_frame_end (), (res))
|
||||||
#define TRACE_SYSERR(res) \
|
#define TRACE_SYSERR(res) \
|
||||||
res == 0 ? ((void) (TRACE_SUC ("result=%i", res)), (res)) : \
|
res == 0 ? ((void) (TRACE_SUC ("result=%i", res)), (res)) : \
|
||||||
(_gpgme_debug (_gpgme_trace_level, "%s: error: %s\n", \
|
(_gpgme_debug (_gpgme_trace_level, -1, NULL, NULL, NULL, \
|
||||||
|
"%s: error: %s\n", \
|
||||||
_gpgme_trace_func, strerror (res)), \
|
_gpgme_trace_func, strerror (res)), \
|
||||||
_gpgme_debug_frame_end (), (res))
|
_gpgme_debug_frame_end (), (res))
|
||||||
#define TRACE_SYSERR_NR(res) \
|
#define TRACE_SYSERR_NR(res) \
|
||||||
do { res == 0 ? ((void) (TRACE_SUC ("result=%i", res)), (res)) : \
|
do { res == 0 ? ((void) (TRACE_SUC ("result=%i", res)), (res)) : \
|
||||||
(_gpgme_debug (_gpgme_trace_level, "%s: error: %s\n", \
|
(_gpgme_debug (_gpgme_trace_level, -1, NULL, NULL, NULL, \
|
||||||
|
"%s: error: %s\n", \
|
||||||
_gpgme_trace_func, strerror (res)), \
|
_gpgme_trace_func, strerror (res)), \
|
||||||
_gpgme_debug_frame_end ()); } while (0)
|
_gpgme_debug_frame_end ()); } while (0)
|
||||||
|
|
||||||
#define TRACE_SUC(...) \
|
#define TRACE_SUC(...) \
|
||||||
_gpgme_debugf (_gpgme_trace_level, 3, _gpgme_trace_func, NULL, NULL, \
|
_gpgme_debug (_gpgme_trace_level, 3, _gpgme_trace_func, NULL, NULL, \
|
||||||
__VA_ARGS__), _gpgme_debug_frame_end ()
|
__VA_ARGS__), _gpgme_debug_frame_end ()
|
||||||
|
|
||||||
#define TRACE_LOG(...) \
|
#define TRACE_LOG(...) \
|
||||||
_gpgme_debugf (_gpgme_trace_level, 2, \
|
_gpgme_debug (_gpgme_trace_level, 2, \
|
||||||
_gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \
|
_gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \
|
||||||
__VA_ARGS__)
|
__VA_ARGS__)
|
||||||
|
|
||||||
|
@ -262,13 +262,14 @@ get_gpgconf_item (int what)
|
|||||||
pgmname = dirinfo.disable_gpgconf? NULL : _gpgme_get_gpgconf_path ();
|
pgmname = dirinfo.disable_gpgconf? NULL : _gpgme_get_gpgconf_path ();
|
||||||
if (pgmname && access (pgmname, F_OK))
|
if (pgmname && access (pgmname, F_OK))
|
||||||
{
|
{
|
||||||
_gpgme_debug (DEBUG_INIT,
|
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL,
|
||||||
"gpgme-dinfo: gpgconf='%s' [not installed]\n", pgmname);
|
"gpgme-dinfo: gpgconf='%s' [not installed]\n", pgmname);
|
||||||
free (pgmname);
|
free (pgmname);
|
||||||
pgmname = NULL; /* Not available. */
|
pgmname = NULL; /* Not available. */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_gpgme_debug (DEBUG_INIT, "gpgme-dinfo: gpgconf='%s'\n",
|
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL,
|
||||||
|
"gpgme-dinfo: gpgconf='%s'\n",
|
||||||
pgmname? pgmname : "[null]");
|
pgmname? pgmname : "[null]");
|
||||||
if (!pgmname)
|
if (!pgmname)
|
||||||
{
|
{
|
||||||
@ -294,28 +295,36 @@ get_gpgconf_item (int what)
|
|||||||
allocated. */
|
allocated. */
|
||||||
dirinfo.valid = 1;
|
dirinfo.valid = 1;
|
||||||
if (dirinfo.gpg_name)
|
if (dirinfo.gpg_name)
|
||||||
_gpgme_debug (DEBUG_INIT, "gpgme-dinfo: gpg='%s'\n",
|
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL,
|
||||||
|
"gpgme-dinfo: gpg='%s'\n",
|
||||||
dirinfo.gpg_name);
|
dirinfo.gpg_name);
|
||||||
if (dirinfo.g13_name)
|
if (dirinfo.g13_name)
|
||||||
_gpgme_debug (DEBUG_INIT, "gpgme-dinfo: g13='%s'\n",
|
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL,
|
||||||
|
"gpgme-dinfo: g13='%s'\n",
|
||||||
dirinfo.g13_name);
|
dirinfo.g13_name);
|
||||||
if (dirinfo.gpgsm_name)
|
if (dirinfo.gpgsm_name)
|
||||||
_gpgme_debug (DEBUG_INIT, "gpgme-dinfo: gpgsm='%s'\n",
|
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL,
|
||||||
|
"gpgme-dinfo: gpgsm='%s'\n",
|
||||||
dirinfo.gpgsm_name);
|
dirinfo.gpgsm_name);
|
||||||
if (dirinfo.homedir)
|
if (dirinfo.homedir)
|
||||||
_gpgme_debug (DEBUG_INIT, "gpgme-dinfo: homedir='%s'\n",
|
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL,
|
||||||
|
"gpgme-dinfo: homedir='%s'\n",
|
||||||
dirinfo.homedir);
|
dirinfo.homedir);
|
||||||
if (dirinfo.agent_socket)
|
if (dirinfo.agent_socket)
|
||||||
_gpgme_debug (DEBUG_INIT, "gpgme-dinfo: agent='%s'\n",
|
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL,
|
||||||
|
"gpgme-dinfo: agent='%s'\n",
|
||||||
dirinfo.agent_socket);
|
dirinfo.agent_socket);
|
||||||
if (dirinfo.agent_ssh_socket)
|
if (dirinfo.agent_ssh_socket)
|
||||||
_gpgme_debug (DEBUG_INIT, "gpgme-dinfo: ssh='%s'\n",
|
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL,
|
||||||
|
"gpgme-dinfo: ssh='%s'\n",
|
||||||
dirinfo.agent_ssh_socket);
|
dirinfo.agent_ssh_socket);
|
||||||
if (dirinfo.dirmngr_socket)
|
if (dirinfo.dirmngr_socket)
|
||||||
_gpgme_debug (DEBUG_INIT, "gpgme-dinfo: dirmngr='%s'\n",
|
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL,
|
||||||
|
"gpgme-dinfo: dirmngr='%s'\n",
|
||||||
dirinfo.dirmngr_socket);
|
dirinfo.dirmngr_socket);
|
||||||
if (dirinfo.uisrv_socket)
|
if (dirinfo.uisrv_socket)
|
||||||
_gpgme_debug (DEBUG_INIT, "gpgme-dinfo: uisrv='%s'\n",
|
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL,
|
||||||
|
"gpgme-dinfo: uisrv='%s'\n",
|
||||||
dirinfo.uisrv_socket);
|
dirinfo.uisrv_socket);
|
||||||
}
|
}
|
||||||
switch (what)
|
switch (what)
|
||||||
|
@ -114,7 +114,8 @@ walk_path (const char *pgm)
|
|||||||
path = s + 1;
|
path = s + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_gpgme_debug (DEBUG_ENGINE, "gpgme-walk_path: '%s' not found in '%s'",
|
_gpgme_debug (DEBUG_ENGINE, -1, NULL, NULL, NULL,
|
||||||
|
"gpgme-walk_path: '%s' not found in '%s'",
|
||||||
pgm, orig_path);
|
pgm, orig_path);
|
||||||
|
|
||||||
free (fname);
|
free (fname);
|
||||||
|
@ -532,7 +532,8 @@ _gpgme_get_gpg_path (void)
|
|||||||
|
|
||||||
/* 4. Print a debug message if not found. */
|
/* 4. Print a debug message if not found. */
|
||||||
if (!gpg)
|
if (!gpg)
|
||||||
_gpgme_debug (DEBUG_ENGINE, "_gpgme_get_gpg_path: '%s' not found", name);
|
_gpgme_debug (DEBUG_ENGINE, -1, NULL, NULL, NULL,
|
||||||
|
"_gpgme_get_gpg_path: '%s' not found", name);
|
||||||
|
|
||||||
return gpg;
|
return gpg;
|
||||||
}
|
}
|
||||||
@ -607,7 +608,8 @@ _gpgme_get_gpgconf_path (void)
|
|||||||
|
|
||||||
/* 5. Print a debug message if not found. */
|
/* 5. Print a debug message if not found. */
|
||||||
if (!gpgconf)
|
if (!gpgconf)
|
||||||
_gpgme_debug (DEBUG_ENGINE, "_gpgme_get_gpgconf_path: '%s' not found",name);
|
_gpgme_debug (DEBUG_ENGINE, -1, NULL, NULL, NULL,
|
||||||
|
"_gpgme_get_gpgconf_path: '%s' not found",name);
|
||||||
|
|
||||||
return gpgconf;
|
return gpgconf;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user