service.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
  3. * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License version 2.1
  7. * as published by the Free Software Foundation
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #ifndef __PROCD_SERVICE_H
  15. #define __PROCD_SERVICE_H
  16. #include <libubox/avl.h>
  17. #include <libubox/vlist.h>
  18. #include <libubox/list.h>
  19. extern struct avl_tree services;
  20. struct vrule {
  21. struct avl_node avl;
  22. char *option;
  23. char *rule;
  24. };
  25. struct validate {
  26. struct avl_node avl;
  27. struct list_head list;
  28. char *package;
  29. char *type;
  30. struct avl_tree rules;
  31. };
  32. struct service {
  33. struct avl_node avl;
  34. const char *name;
  35. struct blob_attr *trigger;
  36. struct vlist_tree instances;
  37. struct list_head validators;
  38. };
  39. void service_validate_add(struct service *s, struct blob_attr *attr);
  40. void service_validate_dump(struct blob_buf *b, struct service *s);
  41. void service_validate_dump_all(struct blob_buf *b, char *p, char *s);
  42. int service_start_early(char *name, char *cmdline);
  43. void service_stopped(struct service *s);
  44. void service_validate_del(struct service *s);
  45. void service_event(const char *type, const char *service, const char *instance);
  46. #endif