event_template.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * @file event_template.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_MODULES_EVENT_TEMPLATE_H
  23. #define BADVPN_NCD_MODULES_EVENT_TEMPLATE_H
  24. #include <structure/LinkedList1.h>
  25. #include <stringmap/BStringMap.h>
  26. #include <ncd/NCDModule.h>
  27. typedef void (*event_template_func_free) (void *user);
  28. typedef struct {
  29. NCDModuleInst *i;
  30. int blog_channel;
  31. void *user;
  32. event_template_func_free func_free;
  33. struct event_template_event *events;
  34. LinkedList1 events_list;
  35. LinkedList1 free_list;
  36. int enabled;
  37. BStringMap enabled_map;
  38. } event_template;
  39. struct event_template_event {
  40. BStringMap map;
  41. LinkedList1Node events_list_node;
  42. };
  43. void event_template_new (event_template *o, NCDModuleInst *i, int blog_channel, int maxevents, void *user,
  44. event_template_func_free func_free);
  45. void event_template_die (event_template *o);
  46. int event_template_getvar (event_template *o, const char *name, NCDValue *out);
  47. void event_template_queue (event_template *o, BStringMap map, int *out_was_empty);
  48. void event_template_dequeue (event_template *o, int *out_is_empty);
  49. void event_template_assert_enabled (event_template *o);
  50. #endif