conftypes.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #ifndef TOR_SRC_LIB_CONF_CONFTYPES_H
  11. #define TOR_SRC_LIB_CONF_CONFTYPES_H
  12. #include "lib/cc/torint.h"
  13. /** Enumeration of types which option values can take */
  14. typedef enum config_type_t {
  15. CONFIG_TYPE_STRING = 0, /**< An arbitrary string. */
  16. CONFIG_TYPE_FILENAME, /**< A filename: some prefixes get expanded. */
  17. CONFIG_TYPE_POSINT, /**< A non-negative integer less than MAX_INT */
  18. CONFIG_TYPE_INT, /**< Any integer. */
  19. CONFIG_TYPE_UINT64, /**< A value in range 0..UINT64_MAX */
  20. CONFIG_TYPE_INTERVAL, /**< A number of seconds, with optional units*/
  21. CONFIG_TYPE_MSEC_INTERVAL,/**< A number of milliseconds, with optional
  22. * units */
  23. CONFIG_TYPE_MEMUNIT, /**< A number of bytes, with optional units*/
  24. CONFIG_TYPE_DOUBLE, /**< A floating-point value */
  25. CONFIG_TYPE_BOOL, /**< A boolean value, expressed as 0 or 1. */
  26. CONFIG_TYPE_AUTOBOOL, /**< A boolean+auto value, expressed 0 for false,
  27. * 1 for true, and -1 for auto */
  28. CONFIG_TYPE_ISOTIME, /**< An ISO-formatted time relative to UTC. */
  29. CONFIG_TYPE_CSV, /**< A list of strings, separated by commas and
  30. * optional whitespace. */
  31. CONFIG_TYPE_CSV_INTERVAL, /**< A list of strings, separated by commas and
  32. * optional whitespace, representing intervals in
  33. * seconds, with optional units. We allow
  34. * multiple values here for legacy reasons, but
  35. * ignore every value after the first. */
  36. CONFIG_TYPE_LINELIST, /**< Uninterpreted config lines */
  37. CONFIG_TYPE_LINELIST_S, /**< Uninterpreted, context-sensitive config lines,
  38. * mixed with other keywords. */
  39. CONFIG_TYPE_LINELIST_V, /**< Catch-all "virtual" option to summarize
  40. * context-sensitive config lines when fetching.
  41. */
  42. // XXXX this doesn't belong at this level of abstraction.
  43. CONFIG_TYPE_ROUTERSET, /**< A list of router names, addrs, and fps,
  44. * parsed into a routerset_t. */
  45. CONFIG_TYPE_OBSOLETE, /**< Obsolete (ignored) option. */
  46. } config_type_t;
  47. #ifdef TOR_UNIT_TESTS
  48. /**
  49. * Union used when building in test mode typechecking the members of a type
  50. * used with confparse.c. See CONF_CHECK_VAR_TYPE for a description of how
  51. * it is used. */
  52. typedef union {
  53. char **STRING;
  54. char **FILENAME;
  55. int *POSINT; /* yes, really: Even though the confparse type is called
  56. * "POSINT", it still uses the C int type -- it just enforces
  57. * that the values are in range [0,INT_MAX].
  58. */
  59. uint64_t *UINT64;
  60. int *INT;
  61. int *INTERVAL;
  62. int *MSEC_INTERVAL;
  63. uint64_t *MEMUNIT;
  64. double *DOUBLE;
  65. int *BOOL;
  66. int *AUTOBOOL;
  67. time_t *ISOTIME;
  68. struct smartlist_t **CSV;
  69. int *CSV_INTERVAL;
  70. struct config_line_t **LINELIST;
  71. struct config_line_t **LINELIST_S;
  72. struct config_line_t **LINELIST_V;
  73. // XXXX this doesn't belong at this level of abstraction.
  74. struct routerset_t **ROUTERSET;
  75. } confparse_dummy_values_t;
  76. #endif /* defined(TOR_UNIT_TESTS) */
  77. #endif /* !defined(TOR_SRC_LIB_CONF_CONFTYPES_H) */