NCDUdevMonitorParser.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * @file NCDUdevMonitorParser.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_NCDUDEVMONITORPARSER_H
  23. #define BADVPN_UDEVMONITOR_NCDUDEVMONITORPARSER_H
  24. #include <stdint.h>
  25. #include <regex.h>
  26. #include <misc/debug.h>
  27. #include <system/DebugObject.h>
  28. #include <flow/StreamRecvInterface.h>
  29. typedef void (*NCDUdevMonitorParser_handler) (void *user);
  30. struct NCDUdevMonitorParser_property {
  31. char *name;
  32. char *value;
  33. };
  34. typedef struct {
  35. StreamRecvInterface *input;
  36. int buf_size;
  37. int max_properties;
  38. int is_info_mode;
  39. void *user;
  40. NCDUdevMonitorParser_handler handler;
  41. regex_t property_regex;
  42. BPending done_job;
  43. uint8_t *buf;
  44. int buf_used;
  45. int is_ready;
  46. int ready_len;
  47. int ready_is_ready_event;
  48. struct NCDUdevMonitorParser_property *ready_properties;
  49. int ready_num_properties;
  50. DebugObject d_obj;
  51. } NCDUdevMonitorParser;
  52. int NCDUdevMonitorParser_Init (NCDUdevMonitorParser *o, StreamRecvInterface *input, int buf_size, int max_properties,
  53. int is_info_mode, BPendingGroup *pg, void *user,
  54. NCDUdevMonitorParser_handler handler) WARN_UNUSED;
  55. void NCDUdevMonitorParser_Free (NCDUdevMonitorParser *o);
  56. void NCDUdevMonitorParser_AssertReady (NCDUdevMonitorParser *o);
  57. void NCDUdevMonitorParser_Done (NCDUdevMonitorParser *o);
  58. int NCDUdevMonitorParser_IsReadyEvent (NCDUdevMonitorParser *o);
  59. int NCDUdevMonitorParser_GetNumProperties (NCDUdevMonitorParser *o);
  60. void NCDUdevMonitorParser_GetProperty (NCDUdevMonitorParser *o, int index, const char **name, const char **value);
  61. #endif