storage.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (C) 2007 Martin Willi
  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 storage storage
  17. * @{ @ingroup manager
  18. */
  19. #ifndef STORAGE_H_
  20. #define STORAGE_H_
  21. #include <collections/enumerator.h>
  22. typedef struct storage_t storage_t;
  23. /**
  24. * Persistent database storage.
  25. */
  26. struct storage_t {
  27. /**
  28. * Try to log in using specified credentials.
  29. *
  30. * @param username username
  31. * @param password plaintext password
  32. * @return user ID if login good, 0 otherwise
  33. */
  34. int (*login)(storage_t *this, char *username, char *password);
  35. /**
  36. * Create an enumerator over the gateways.
  37. *
  38. * enumerate() arguments: int id, char *name, int port, char *address
  39. * If port is 0, address is a Unix socket address.
  40. *
  41. * @param user user Id
  42. * @return enumerator
  43. */
  44. enumerator_t* (*create_gateway_enumerator)(storage_t *this, int user);
  45. /**
  46. * Destroy a storage instance.
  47. */
  48. void (*destroy)(storage_t *this);
  49. };
  50. /**
  51. * Create a storage instance.
  52. *
  53. * @param uri database connection URI
  54. */
  55. storage_t *storage_create(char *uri);
  56. #endif /** STORAGE_H_ @}*/