NCDUdevCache.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * @file NCDUdevCache.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_NCDUDEVCACHE_H
  23. #define BADVPN_UDEVMONITOR_NCDUDEVCACHE_H
  24. #include <misc/debug.h>
  25. #include <structure/BAVL.h>
  26. #include <structure/LinkedList1.h>
  27. #include <system/DebugObject.h>
  28. #include <stringmap/BStringMap.h>
  29. struct NCDUdevCache_device {
  30. BStringMap map;
  31. const char *devpath;
  32. int is_cleaned;
  33. union {
  34. BAVLNode devices_tree_node;
  35. LinkedList1Node cleaned_devices_list_node;
  36. };
  37. int is_refreshed;
  38. };
  39. typedef struct {
  40. BAVL devices_tree;
  41. LinkedList1 cleaned_devices_list;
  42. DebugObject d_obj;
  43. } NCDUdevCache;
  44. void NCDUdevCache_Init (NCDUdevCache *o);
  45. void NCDUdevCache_Free (NCDUdevCache *o);
  46. const BStringMap * NCDUdevCache_Query (NCDUdevCache *o, const char *devpath);
  47. int NCDUdevCache_Event (NCDUdevCache *o, BStringMap map) WARN_UNUSED;
  48. void NCDUdevCache_StartClean (NCDUdevCache *o);
  49. void NCDUdevCache_FinishClean (NCDUdevCache *o);
  50. int NCDUdevCache_GetCleanedDevice (NCDUdevCache *o, BStringMap *out_map);
  51. const char * NCDUdevCache_First (NCDUdevCache *o);
  52. const char * NCDUdevCache_Next (NCDUdevCache *o, const char *key);
  53. #endif