mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Stringify all the CONF_foo identifiers, for debugging.
When dumping out the contents of a Conf, it's useful not to have to guess what the integer indices mean. By putting these identifiers in a separate array in its own library module, I should avoid them getting linked in to production binaries to take up space, as long as conf_id() is only called from inside debug() statements. And to enforce _that_, it isn't even declared in a header file unless you #define DEBUG.
This commit is contained in:
parent
31ab5b8e30
commit
964890f1a1
5
misc.h
5
misc.h
@ -339,6 +339,11 @@ void debug_memdump(const void *buf, int len, bool L);
|
|||||||
#define debug(...) (debug_printf(__VA_ARGS__))
|
#define debug(...) (debug_printf(__VA_ARGS__))
|
||||||
#define dmemdump(buf,len) (debug_memdump(buf, len, false))
|
#define dmemdump(buf,len) (debug_memdump(buf, len, false))
|
||||||
#define dmemdumpl(buf,len) (debug_memdump(buf, len, true))
|
#define dmemdumpl(buf,len) (debug_memdump(buf, len, true))
|
||||||
|
|
||||||
|
/* Functions used only for debugging, not declared unless
|
||||||
|
* defined(DEBUG) to avoid accidentally linking them in production */
|
||||||
|
const char *conf_id(int key);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define debug(...) ((void)0)
|
#define debug(...) ((void)0)
|
||||||
#define dmemdump(buf,len) ((void)0)
|
#define dmemdump(buf,len) ((void)0)
|
||||||
|
@ -16,6 +16,7 @@ add_sources_from_current_dir(utils
|
|||||||
conf.c
|
conf.c
|
||||||
conf_data.c
|
conf_data.c
|
||||||
conf_dest.c
|
conf_dest.c
|
||||||
|
conf_debug.c
|
||||||
conf_launchable.c
|
conf_launchable.c
|
||||||
ctrlparse.c
|
ctrlparse.c
|
||||||
ctrlset_normalise.c
|
ctrlset_normalise.c
|
||||||
|
15
utils/conf_debug.c
Normal file
15
utils/conf_debug.c
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include "putty.h"
|
||||||
|
|
||||||
|
#define CONF_OPTION(id, ...) "CONF_" #id,
|
||||||
|
|
||||||
|
static const char *const conf_debug_identifiers[] = {
|
||||||
|
#include "conf.h"
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *conf_id(int key)
|
||||||
|
{
|
||||||
|
size_t i = key;
|
||||||
|
if (i < lenof(conf_debug_identifiers))
|
||||||
|
return conf_debug_identifiers[i];
|
||||||
|
return "CONF_!outofrange!";
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user