confline.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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-2018, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. #ifndef TOR_CONFLINE_H
  7. #define TOR_CONFLINE_H
  8. struct smartlist_t;
  9. /** Ordinary configuration line. */
  10. #define CONFIG_LINE_NORMAL 0
  11. /** Appends to previous configuration for the same option, even if we
  12. * would ordinary replace it. */
  13. #define CONFIG_LINE_APPEND 1
  14. /* Removes all previous configuration for an option. */
  15. #define CONFIG_LINE_CLEAR 2
  16. #define MAX_INCLUDE_RECURSION_LEVEL 31
  17. /** A linked list of lines in a config file, or elsewhere */
  18. typedef struct config_line_t {
  19. char *key;
  20. char *value;
  21. struct config_line_t *next;
  22. /** What special treatment (if any) does this line require? */
  23. unsigned int command:2;
  24. /** If true, subsequent assignments to this linelist should replace
  25. * it, not extend it. Set only on the first item in a linelist in an
  26. * or_options_t. */
  27. unsigned int fragile:1;
  28. } config_line_t;
  29. void config_line_append(config_line_t **lst,
  30. const char *key, const char *val);
  31. void config_line_prepend(config_line_t **lst,
  32. const char *key, const char *val);
  33. config_line_t *config_lines_dup(const config_line_t *inp);
  34. config_line_t *config_lines_dup_and_filter(const config_line_t *inp,
  35. const char *key);
  36. const config_line_t *config_line_find(const config_line_t *lines,
  37. const char *key);
  38. int config_lines_eq(config_line_t *a, config_line_t *b);
  39. int config_count_key(const config_line_t *a, const char *key);
  40. void config_free_lines_(config_line_t *front);
  41. #define config_free_lines(front) \
  42. do { \
  43. config_free_lines_(front); \
  44. (front) = NULL; \
  45. } while (0)
  46. const char *parse_config_line_from_str_verbose(const char *line,
  47. char **key_out, char **value_out,
  48. const char **err_out);
  49. int config_get_lines(const char *string, struct config_line_t **result,
  50. int extended);
  51. typedef int (*include_handler_fn)(const char *, int, int,
  52. struct config_line_t **,
  53. struct config_line_t **,
  54. struct smartlist_t *);
  55. int config_get_lines_aux(const char *string, struct config_line_t **result,
  56. int extended,
  57. int allow_include, int *has_include,
  58. struct smartlist_t *opened_lst, int recursion_level,
  59. config_line_t **last,
  60. include_handler_fn handle_include);
  61. #endif /* !defined(TOR_CONFLINE_H) */