db.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2018 Markus Hennecke <markus-hennecke@markus-hennecke.de>
  3. *
  4. * Permission to use, copy, modify, and distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef __DB_H__
  17. #define __DB_H__
  18. #include <stdbool.h>
  19. #include <kcgi.h>
  20. bool db_connect(struct kreq *);
  21. void db_disconnect(void);
  22. bool db_add_data(struct kreq *, const char *temp, const char *humidity,
  23. const char *pressure, const char *battery);
  24. bool db_add_error(struct kreq *, const char *device, const char *timestamp,
  25. const char *errormsg);
  26. bool db_get_data_json(struct kreq *, char **, const char *, const char *);
  27. bool db_get_errors_json(struct kreq *, char **, const char *);
  28. bool db_get_latest_json(struct kreq *, char **, const char *, const char *);
  29. bool db_get_statistics_data_json(struct kreq *, char **, const char *,
  30. const char *);
  31. #endif