mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Use structvar to find the types for config vars.
This commit is contained in:
parent
53e969c137
commit
a91ed23403
@ -30,7 +30,7 @@
|
||||
# Remember: It is better to fix the problem than to add a new exception!
|
||||
|
||||
problem file-size /src/app/config/config.c 8518
|
||||
problem include-count /src/app/config/config.c 87
|
||||
problem include-count /src/app/config/config.c 88
|
||||
problem function-size /src/app/config/config.c:options_act_reversible() 296
|
||||
problem function-size /src/app/config/config.c:options_act() 589
|
||||
problem function-size /src/app/config/config.c:resolve_my_address() 192
|
||||
|
@ -111,6 +111,7 @@
|
||||
#include "feature/stats/predict_ports.h"
|
||||
#include "feature/stats/rephist.h"
|
||||
#include "lib/compress/compress.h"
|
||||
#include "lib/confmgt/structvar.h"
|
||||
#include "lib/crypt_ops/crypto_init.h"
|
||||
#include "lib/crypt_ops/crypto_rand.h"
|
||||
#include "lib/crypt_ops/crypto_util.h"
|
||||
@ -8195,37 +8196,10 @@ getinfo_helper_config(control_connection_t *conn,
|
||||
int i;
|
||||
for (i = 0; option_vars_[i].member.name; ++i) {
|
||||
const config_var_t *var = &option_vars_[i];
|
||||
const char *type;
|
||||
/* don't tell controller about triple-underscore options */
|
||||
if (!strncmp(option_vars_[i].member.name, "___", 3))
|
||||
continue;
|
||||
switch (var->member.type) {
|
||||
case CONFIG_TYPE_STRING: type = "String"; break;
|
||||
case CONFIG_TYPE_FILENAME: type = "Filename"; break;
|
||||
case CONFIG_TYPE_POSINT: type = "Integer"; break;
|
||||
case CONFIG_TYPE_UINT64: type = "Integer"; break;
|
||||
case CONFIG_TYPE_INT: type = "SignedInteger"; break;
|
||||
case CONFIG_TYPE_INTERVAL: type = "TimeInterval"; break;
|
||||
case CONFIG_TYPE_MSEC_INTERVAL: type = "TimeMsecInterval"; break;
|
||||
case CONFIG_TYPE_MEMUNIT: type = "DataSize"; break;
|
||||
case CONFIG_TYPE_DOUBLE: type = "Float"; break;
|
||||
case CONFIG_TYPE_BOOL: type = "Boolean"; break;
|
||||
case CONFIG_TYPE_AUTOBOOL: type = "Boolean+Auto"; break;
|
||||
case CONFIG_TYPE_ISOTIME: type = "Time"; break;
|
||||
case CONFIG_TYPE_ROUTERSET: type = "RouterList"; break;
|
||||
case CONFIG_TYPE_CSV: type = "CommaList"; break;
|
||||
/* This type accepts more inputs than TimeInterval, but it ignores
|
||||
* everything after the first entry, so we may as well pretend
|
||||
* it's a TimeInterval. */
|
||||
case CONFIG_TYPE_CSV_INTERVAL: type = "TimeInterval"; break;
|
||||
case CONFIG_TYPE_LINELIST: type = "LineList"; break;
|
||||
case CONFIG_TYPE_LINELIST_S: type = "Dependent"; break;
|
||||
case CONFIG_TYPE_LINELIST_V: type = "Virtual"; break;
|
||||
default:
|
||||
case CONFIG_TYPE_OBSOLETE:
|
||||
case CONFIG_TYPE_EXTENDED:
|
||||
type = NULL; break;
|
||||
}
|
||||
const char *type = struct_var_get_typename(&var->member);
|
||||
if (!type)
|
||||
continue;
|
||||
smartlist_add_asprintf(sl, "%s %s\n",var->member.name,type);
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "lib/confmgt/typedvar.h"
|
||||
#include "lib/log/util_bug.h"
|
||||
|
||||
#include "lib/confmgt/var_type_def_st.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
@ -198,3 +200,27 @@ struct_var_kvencode(const void *object, const struct_member_t *member)
|
||||
|
||||
return typed_var_kvencode_ex(member->name, p, def);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the official name of this struct member.
|
||||
**/
|
||||
const char *
|
||||
struct_var_get_name(const struct_member_t *member)
|
||||
{
|
||||
return member->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the type name for this struct member.
|
||||
*
|
||||
* Do not use the output of this function to inspect a type within Tor. It is
|
||||
* suitable for debugging, informing the controller or user of a variable's
|
||||
* type, etc.
|
||||
**/
|
||||
const char *
|
||||
struct_var_get_typename(const struct_member_t *member)
|
||||
{
|
||||
const var_type_def_t *def = get_type_def(member);
|
||||
|
||||
return def ? def->name : NULL;
|
||||
}
|
||||
|
@ -41,6 +41,9 @@ bool struct_var_eq(const void *a, const void *b,
|
||||
bool struct_var_ok(const void *object,
|
||||
const struct struct_member_t *member);
|
||||
|
||||
const char *struct_var_get_name(const struct struct_member_t *member);
|
||||
const char *struct_var_get_typename(const struct struct_member_t *member);
|
||||
|
||||
int struct_var_kvassign(void *object, const struct config_line_t *line,
|
||||
char **errmsg,
|
||||
const struct struct_member_t *member);
|
||||
|
Loading…
Reference in New Issue
Block a user