service.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #include "../utils/utils.h"
  20. extern struct avl_tree services;
  21. extern struct avl_tree containers;
  22. struct vrule {
  23. struct avl_node avl;
  24. char *option;
  25. char *rule;
  26. };
  27. struct validate {
  28. struct avl_node avl;
  29. struct list_head list;
  30. char *package;
  31. char *type;
  32. struct avl_tree rules;
  33. };
  34. struct service {
  35. struct avl_node avl;
  36. const char *name;
  37. bool deleted;
  38. bool autostart;
  39. bool container;
  40. struct blob_attr *trigger;
  41. struct vlist_tree instances;
  42. struct list_head validators;
  43. struct blob_attr *data;
  44. struct blobmsg_list data_blob;
  45. };
  46. void service_validate_add(struct service *s, struct blob_attr *attr);
  47. void service_validate_dump(struct blob_buf *b, struct service *s);
  48. void service_validate_dump_all(struct blob_buf *b, char *p, char *s);
  49. int service_start_early(char *name, char *cmdline, char *user, char *group);
  50. void service_stopped(struct service *s);
  51. void service_validate_del(struct service *s);
  52. void service_event(const char *type, const char *service, const char *instance);
  53. void service_stop_all(void);
  54. #endif