confline.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. /** A linked list of lines in a config file, or elsewhere */
  16. typedef struct config_line_t {
  17. char *key;
  18. char *value;
  19. struct config_line_t *next;
  20. /** What special treatment (if any) does this line require? */
  21. unsigned int command:2;
  22. /** If true, subsequent assignments to this linelist should replace
  23. * it, not extend it. Set only on the first item in a linelist in an
  24. * or_options_t. */
  25. unsigned int fragile:1;
  26. } config_line_t;
  27. void config_line_append(config_line_t **lst,
  28. const char *key, const char *val);
  29. void config_line_prepend(config_line_t **lst,
  30. const char *key, const char *val);
  31. config_line_t *config_lines_dup(const config_line_t *inp);
  32. config_line_t *config_lines_dup_and_filter(const config_line_t *inp,
  33. const char *key);
  34. const config_line_t *config_line_find(const config_line_t *lines,
  35. const char *key);
  36. int config_lines_eq(config_line_t *a, config_line_t *b);
  37. int config_count_key(const config_line_t *a, const char *key);
  38. int config_get_lines(const char *string, config_line_t **result, int extended);
  39. void config_free_lines(config_line_t *front);
  40. const char *parse_config_line_from_str_verbose(const char *line,
  41. char **key_out, char **value_out,
  42. const char **err_out);
  43. #endif