NCDUdevManager.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * @file NCDUdevManager.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_UDEVMONITOR_NCDUDEVMANAGER_H
  23. #define BADVPN_UDEVMONITOR_NCDUDEVMANAGER_H
  24. #include <misc/debug.h>
  25. #include <structure/LinkedList1.h>
  26. #include <system/DebugObject.h>
  27. #include <udevmonitor/NCDUdevMonitor.h>
  28. #include <udevmonitor/NCDUdevCache.h>
  29. #include <stringmap/BStringMap.h>
  30. typedef void (*NCDUdevClient_handler) (void *user, char *devpath, int have_map, BStringMap map);
  31. typedef struct {
  32. BReactor *reactor;
  33. BProcessManager *manager;
  34. LinkedList1 clients_list;
  35. NCDUdevCache cache;
  36. BTimer restart_timer;
  37. int have_monitor;
  38. NCDUdevMonitor monitor;
  39. int have_info_monitor;
  40. NCDUdevMonitor info_monitor;
  41. DebugObject d_obj;
  42. } NCDUdevManager;
  43. typedef struct {
  44. NCDUdevManager *m;
  45. void *user;
  46. NCDUdevClient_handler handler;
  47. LinkedList1Node clients_list_node;
  48. LinkedList1 events_list;
  49. BPending next_job;
  50. int running;
  51. DebugObject d_obj;
  52. } NCDUdevClient;
  53. struct NCDUdevClient_event {
  54. char *devpath;
  55. int have_map;
  56. BStringMap map;
  57. LinkedList1Node events_list_node;
  58. };
  59. void NCDUdevManager_Init (NCDUdevManager *o, BReactor *reactor, BProcessManager *manager);
  60. void NCDUdevManager_Free (NCDUdevManager *o);
  61. const BStringMap * NCDUdevManager_Query (NCDUdevManager *o, const char *devpath);
  62. void NCDUdevClient_Init (NCDUdevClient *o, NCDUdevManager *m, void *user,
  63. NCDUdevClient_handler handler);
  64. void NCDUdevClient_Free (NCDUdevClient *o);
  65. void NCDUdevClient_Pause (NCDUdevClient *o);
  66. void NCDUdevClient_Continue (NCDUdevClient *o);
  67. #endif