NCDConfig.h 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**
  2. * @file NCDConfig.h
  3. * @author Ambroz Bizjak <ambrop7@gmail.com>
  4. *
  5. * @section LICENSE
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. Neither the name of the author nor the
  15. * names of its contributors may be used to endorse or promote products
  16. * derived from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. */
  29. #ifndef BADVPN_NCDCONFIG_NCDCONFIG_H
  30. #define BADVPN_NCDCONFIG_NCDCONFIG_H
  31. struct NCDConfig_processes;
  32. struct NCDConfig_statements;
  33. struct NCDConfig_list;
  34. struct NCDConfig_strings;
  35. struct NCDConfig_processes {
  36. int is_template;
  37. char *name;
  38. struct NCDConfig_statements *statements;
  39. struct NCDConfig_processes *next;
  40. };
  41. struct NCDConfig_statements {
  42. struct NCDConfig_strings *objname;
  43. struct NCDConfig_strings *names;
  44. struct NCDConfig_list *args;
  45. char *name;
  46. struct NCDConfig_statements *next;
  47. };
  48. #define NCDCONFIG_ARG_STRING 1
  49. #define NCDCONFIG_ARG_VAR 2
  50. #define NCDCONFIG_ARG_LIST 3
  51. struct NCDConfig_list {
  52. int type;
  53. union {
  54. char *string;
  55. struct NCDConfig_strings *var;
  56. struct NCDConfig_list *list;
  57. };
  58. struct NCDConfig_list *next;
  59. };
  60. struct NCDConfig_strings {
  61. char *value;
  62. struct NCDConfig_strings *next;
  63. };
  64. void NCDConfig_free_processes (struct NCDConfig_processes *v);
  65. void NCDConfig_free_statements (struct NCDConfig_statements *v);
  66. void NCDConfig_free_list (struct NCDConfig_list *v);
  67. void NCDConfig_free_strings (struct NCDConfig_strings *v);
  68. struct NCDConfig_processes * NCDConfig_make_processes (int is_template, char *name, struct NCDConfig_statements *statements, int have_next, struct NCDConfig_processes *next);
  69. struct NCDConfig_statements * NCDConfig_make_statements (struct NCDConfig_strings *objname, struct NCDConfig_strings *names, struct NCDConfig_list *args, char *name, struct NCDConfig_statements *next);
  70. struct NCDConfig_list * NCDConfig_make_list_string (char *str, struct NCDConfig_list *next);
  71. struct NCDConfig_list * NCDConfig_make_list_var (struct NCDConfig_strings *var, struct NCDConfig_list *next);
  72. struct NCDConfig_list * NCDConfig_make_list_list (struct NCDConfig_list *list, struct NCDConfig_list *next);
  73. struct NCDConfig_strings * NCDConfig_make_strings (char *value, int have_next, struct NCDConfig_strings *next);
  74. int NCDConfig_statement_name_is (struct NCDConfig_statements *st, const char *needle);
  75. struct NCDConfig_statements * NCDConfig_find_statement (struct NCDConfig_statements *st, const char *needle);
  76. char * NCDConfig_concat_strings (struct NCDConfig_strings *s);
  77. #endif