NCDConfig.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * @file NCDConfig.h
  3. * @author Ambroz Bizjak <ambrop7@gmail.com>
  4. *
  5. * @section LICENSE
  6. *
  7. * This file is part of BadVPN.
  8. *
  9. * BadVPN is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2
  11. * as published by the Free Software Foundation.
  12. *
  13. * BadVPN is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. */
  22. #ifndef BADVPN_NCDCONFIG_NCDCONFIG_H
  23. #define BADVPN_NCDCONFIG_NCDCONFIG_H
  24. struct NCDConfig_interfaces;
  25. struct NCDConfig_statements;
  26. struct NCDConfig_arguments;
  27. struct NCDConfig_strings;
  28. struct NCDConfig_interfaces {
  29. char *name;
  30. struct NCDConfig_statements *statements;
  31. struct NCDConfig_interfaces *next;
  32. };
  33. struct NCDConfig_statements {
  34. struct NCDConfig_strings *names;
  35. struct NCDConfig_arguments *args;
  36. char *name;
  37. struct NCDConfig_statements *next;
  38. };
  39. #define NCDCONFIG_ARG_STRING 1
  40. #define NCDCONFIG_ARG_VAR 2
  41. struct NCDConfig_arguments {
  42. int type;
  43. union {
  44. char *string;
  45. struct NCDConfig_strings *var;
  46. };
  47. struct NCDConfig_arguments *next;
  48. };
  49. struct NCDConfig_strings {
  50. char *value;
  51. struct NCDConfig_strings *next;
  52. };
  53. void NCDConfig_free_interfaces (struct NCDConfig_interfaces *v);
  54. void NCDConfig_free_statements (struct NCDConfig_statements *v);
  55. void NCDConfig_free_arguments (struct NCDConfig_arguments *v);
  56. void NCDConfig_free_strings (struct NCDConfig_strings *v);
  57. struct NCDConfig_interfaces * NCDConfig_make_interfaces (char *name, struct NCDConfig_statements *statements, int have_next, struct NCDConfig_interfaces *next);
  58. struct NCDConfig_statements * NCDConfig_make_statements (struct NCDConfig_strings *names, struct NCDConfig_arguments *args, char *name, struct NCDConfig_statements *next);
  59. struct NCDConfig_arguments * NCDConfig_make_arguments_string (char *str, int have_next, struct NCDConfig_arguments *next);
  60. struct NCDConfig_arguments * NCDConfig_make_arguments_var (struct NCDConfig_strings *var, int have_next, struct NCDConfig_arguments *next);
  61. struct NCDConfig_strings * NCDConfig_make_strings (char *value, int have_next, struct NCDConfig_strings *next);
  62. int NCDConfig_statement_name_is (struct NCDConfig_statements *st, const char *needle);
  63. struct NCDConfig_statements * NCDConfig_find_statement (struct NCDConfig_statements *st, const char *needle);
  64. char * NCDConfig_concat_strings (struct NCDConfig_strings *s);
  65. #endif