NCDConfig.h 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. #include <stddef.h>
  32. struct NCDConfig_processes;
  33. struct NCDConfig_statements;
  34. struct NCDConfig_list;
  35. struct NCDConfig_strings;
  36. struct NCDConfig_processes {
  37. int is_template;
  38. char *name;
  39. struct NCDConfig_statements *statements;
  40. struct NCDConfig_processes *next;
  41. };
  42. struct NCDConfig_statements {
  43. struct NCDConfig_strings *objname;
  44. struct NCDConfig_strings *names;
  45. struct NCDConfig_list *args;
  46. char *name;
  47. struct NCDConfig_statements *next;
  48. };
  49. #define NCDCONFIG_ARG_STRING 1
  50. #define NCDCONFIG_ARG_VAR 2
  51. #define NCDCONFIG_ARG_LIST 3
  52. #define NCDCONFIG_ARG_MAPLIST 4
  53. struct NCDConfig_list {
  54. int type;
  55. union {
  56. struct {
  57. char *string;
  58. size_t string_len;
  59. };
  60. struct NCDConfig_strings *var;
  61. struct NCDConfig_list *list;
  62. };
  63. struct NCDConfig_list *next;
  64. };
  65. struct NCDConfig_strings {
  66. char *value;
  67. struct NCDConfig_strings *next;
  68. };
  69. void NCDConfig_free_processes (struct NCDConfig_processes *v);
  70. void NCDConfig_free_statements (struct NCDConfig_statements *v);
  71. void NCDConfig_free_list (struct NCDConfig_list *v);
  72. void NCDConfig_free_strings (struct NCDConfig_strings *v);
  73. struct NCDConfig_processes * NCDConfig_make_processes (int is_template, char *name, struct NCDConfig_statements *statements, int have_next, struct NCDConfig_processes *next);
  74. struct NCDConfig_statements * NCDConfig_make_statements (struct NCDConfig_strings *objname, struct NCDConfig_strings *names, struct NCDConfig_list *args, char *name, struct NCDConfig_statements *next);
  75. struct NCDConfig_list * NCDConfig_make_list_string (char *str, size_t len, struct NCDConfig_list *next);
  76. struct NCDConfig_list * NCDConfig_make_list_var (struct NCDConfig_strings *var, struct NCDConfig_list *next);
  77. struct NCDConfig_list * NCDConfig_make_list_list (struct NCDConfig_list *list, struct NCDConfig_list *next);
  78. struct NCDConfig_list * NCDConfig_make_list_maplist (struct NCDConfig_list *list, struct NCDConfig_list *next);
  79. struct NCDConfig_strings * NCDConfig_make_strings (char *value, int have_next, struct NCDConfig_strings *next);
  80. int NCDConfig_statement_name_is (struct NCDConfig_statements *st, const char *needle);
  81. struct NCDConfig_statements * NCDConfig_find_statement (struct NCDConfig_statements *st, const char *needle);
  82. char * NCDConfig_concat_strings (struct NCDConfig_strings *s);
  83. #endif