confline.h 2.1 KB

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