conftypes.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* Copyright (c) 2001 Matej Pfajfar.
  2. * Copyright (c) 2001-2004, Roger Dingledine.
  3. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  4. * Copyright (c) 2007-2019, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * @file conftypes.h
  8. * @brief Types used to specify configurable options.
  9. *
  10. * This header defines the types that different modules will use in order to
  11. * declare their configuration and state variables, and tell the configuration
  12. * management code about those variables. From the individual module's point
  13. * of view, its configuration and state are simply data structures.
  14. *
  15. * For defining new variable types, see var_type_def_st.h.
  16. *
  17. * For the code that manipulates variables defined via this module, see
  18. * lib/confmgt/, especially typedvar.h and (later) structvar.h. The
  19. * configuration manager is responsible for encoding, decoding, and
  20. * maintaining the configuration structures used by the various modules.
  21. *
  22. * STATUS NOTE: This is a work in process refactoring. It is not yet possible
  23. * for modules to define their own variables, and much of the configuration
  24. * management code is still in src/app/config/.
  25. **/
  26. #ifndef TOR_SRC_LIB_CONF_CONFTYPES_H
  27. #define TOR_SRC_LIB_CONF_CONFTYPES_H
  28. #include "lib/cc/torint.h"
  29. /** Enumeration of types which option values can take */
  30. typedef enum config_type_t {
  31. CONFIG_TYPE_STRING = 0, /**< An arbitrary string. */
  32. CONFIG_TYPE_FILENAME, /**< A filename: some prefixes get expanded. */
  33. CONFIG_TYPE_POSINT, /**< A non-negative integer less than MAX_INT */
  34. CONFIG_TYPE_INT, /**< Any integer. */
  35. CONFIG_TYPE_UINT64, /**< A value in range 0..UINT64_MAX */
  36. CONFIG_TYPE_INTERVAL, /**< A number of seconds, with optional units*/
  37. CONFIG_TYPE_MSEC_INTERVAL,/**< A number of milliseconds, with optional
  38. * units */
  39. CONFIG_TYPE_MEMUNIT, /**< A number of bytes, with optional units*/
  40. CONFIG_TYPE_DOUBLE, /**< A floating-point value */
  41. CONFIG_TYPE_BOOL, /**< A boolean value, expressed as 0 or 1. */
  42. CONFIG_TYPE_AUTOBOOL, /**< A boolean+auto value, expressed 0 for false,
  43. * 1 for true, and -1 for auto */
  44. CONFIG_TYPE_ISOTIME, /**< An ISO-formatted time relative to UTC. */
  45. CONFIG_TYPE_CSV, /**< A list of strings, separated by commas and
  46. * optional whitespace. */
  47. CONFIG_TYPE_CSV_INTERVAL, /**< A list of strings, separated by commas and
  48. * optional whitespace, representing intervals in
  49. * seconds, with optional units. We allow
  50. * multiple values here for legacy reasons, but
  51. * ignore every value after the first. */
  52. CONFIG_TYPE_LINELIST, /**< Uninterpreted config lines */
  53. CONFIG_TYPE_LINELIST_S, /**< Uninterpreted, context-sensitive config lines,
  54. * mixed with other keywords. */
  55. CONFIG_TYPE_LINELIST_V, /**< Catch-all "virtual" option to summarize
  56. * context-sensitive config lines when fetching.
  57. */
  58. // XXXX this doesn't belong at this level of abstraction.
  59. CONFIG_TYPE_ROUTERSET, /**< A list of router names, addrs, and fps,
  60. * parsed into a routerset_t. */
  61. CONFIG_TYPE_OBSOLETE, /**< Obsolete (ignored) option. */
  62. } config_type_t;
  63. #ifdef TOR_UNIT_TESTS
  64. /**
  65. * Union used when building in test mode typechecking the members of a type
  66. * used with confparse.c. See CONF_CHECK_VAR_TYPE for a description of how
  67. * it is used. */
  68. typedef union {
  69. char **STRING;
  70. char **FILENAME;
  71. int *POSINT; /* yes, really: Even though the confparse type is called
  72. * "POSINT", it still uses the C int type -- it just enforces
  73. * that the values are in range [0,INT_MAX].
  74. */
  75. uint64_t *UINT64;
  76. int *INT;
  77. int *INTERVAL;
  78. int *MSEC_INTERVAL;
  79. uint64_t *MEMUNIT;
  80. double *DOUBLE;
  81. int *BOOL;
  82. int *AUTOBOOL;
  83. time_t *ISOTIME;
  84. struct smartlist_t **CSV;
  85. int *CSV_INTERVAL;
  86. struct config_line_t **LINELIST;
  87. struct config_line_t **LINELIST_S;
  88. struct config_line_t **LINELIST_V;
  89. // XXXX this doesn't belong at this level of abstraction.
  90. struct routerset_t **ROUTERSET;
  91. } confparse_dummy_values_t;
  92. #endif /* defined(TOR_UNIT_TESTS) */
  93. #endif /* !defined(TOR_SRC_LIB_CONF_CONFTYPES_H) */