confline.h 2.9 KB

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