NCDValue.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * @file NCDValue.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_NCD_NCDVALUE_H
  23. #define BADVPN_NCD_NCDVALUE_H
  24. #include <stddef.h>
  25. #include <structure/LinkedList2.h>
  26. #define NCDVALUE_STRING 1
  27. #define NCDVALUE_LIST 2
  28. typedef struct {
  29. int type;
  30. union {
  31. char *string;
  32. LinkedList2 list;
  33. };
  34. } NCDValue;
  35. typedef struct {
  36. LinkedList2Node list_node;
  37. NCDValue v;
  38. } NCDListElement;
  39. int NCDValue_InitCopy (NCDValue *o, NCDValue *v);
  40. void NCDValue_Free (NCDValue *o);
  41. int NCDValue_Type (NCDValue *o);
  42. int NCDValue_InitString (NCDValue *o, char *str);
  43. char * NCDValue_StringValue (NCDValue *o);
  44. void NCDValue_InitList (NCDValue *o);
  45. int NCDValue_ListAppend (NCDValue *o, NCDValue v);
  46. size_t NCDValue_ListCount (NCDValue *o);
  47. NCDValue * NCDValue_ListFirst (NCDValue *o);
  48. NCDValue * NCDValue_ListNext (NCDValue *o, NCDValue *ev);
  49. int NCDValue_ListRead (NCDValue *o, int num, ...);
  50. int NCDValue_ListReadHead (NCDValue *o, int num, ...);
  51. #endif