1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-02 12:02:47 -05: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:
Simon Tatham
2024-09-23 15:12:18 +01:00
parent 31ab5b8e30
commit 964890f1a1
3 changed files with 21 additions and 0 deletions

View File

@ -16,6 +16,7 @@ add_sources_from_current_dir(utils
conf.c
conf_data.c
conf_dest.c
conf_debug.c
conf_launchable.c
ctrlparse.c
ctrlset_normalise.c

15
utils/conf_debug.c Normal file
View 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!";
}