sw_collector_history.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (C) 2017 Andreas Steffen
  3. * HSR Hochschule fuer Technik Rapperswil
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation; either version 2 of the License, or (at your
  8. * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  12. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  13. * for more details.
  14. */
  15. /**
  16. * @defgroup sw_collector_history_t sw_collector_history
  17. * @{ @ingroup sw_collector
  18. */
  19. #ifndef SW_COLLECTOR_HISTORY_H_
  20. #define SW_COLLECTOR_HISTORY_H_
  21. #include "sw_collector_db.h"
  22. #include <library.h>
  23. #include <utils/debug.h>
  24. #include <utils/lexparser.h>
  25. typedef struct sw_collector_history_t sw_collector_history_t;
  26. typedef enum sw_collector_history_op_t sw_collector_history_op_t;
  27. /**
  28. * Define major history event operations
  29. */
  30. enum sw_collector_history_op_t {
  31. SW_OP_INSTALL,
  32. SW_OP_UPGRADE,
  33. SW_OP_REMOVE
  34. };
  35. /**
  36. * Software collector history object
  37. */
  38. struct sw_collector_history_t {
  39. /**
  40. * Extract timestamp from event in installation history
  41. *
  42. * @param args Arguments to be processed
  43. * @param buf timestamp buffer for 21 byte RFC 3339 string
  44. * @return TRUE if extraction succeeded
  45. */
  46. bool (*extract_timestamp)(sw_collector_history_t *this, chunk_t args,
  47. char *buf);
  48. /**
  49. * Extract packages from event in installation history
  50. *
  51. * @param args Arguments to be processed
  52. * @param eid Primary key pointing to current event
  53. * @param op Extraction operation
  54. * @return TRUE if extraction succeeded
  55. */
  56. bool (*extract_packages)(sw_collector_history_t *this, chunk_t args,
  57. uint32_t eid, sw_collector_history_op_t op);
  58. /**
  59. * Merge packages from initial installation
  60. *
  61. * @return TRUE if merge succeeded
  62. */
  63. bool (*merge_installed_packages)(sw_collector_history_t *this);
  64. /**
  65. * Destroy sw_collector_history_t object
  66. */
  67. void (*destroy)(sw_collector_history_t *this);
  68. };
  69. /**
  70. * Create an sw_collector_history_t instance
  71. *
  72. * @param db Internal reference to collector database
  73. * @param source Software event source number
  74. */
  75. sw_collector_history_t* sw_collector_history_create(sw_collector_db_t *db,
  76. uint8_t source);
  77. #endif /** SW_COLLECTOR_HISTORY_H_ @}*/