ma_io.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* Copyright (C) 2015 MariaDB Corporation AB
  2. This library is free software; you can redistribute it and/or
  3. modify it under the terms of the GNU Library General Public
  4. License as published by the Free Software Foundation; either
  5. version 2 of the License, or (at your option) any later version.
  6. This library is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  9. Library General Public License for more details.
  10. You should have received a copy of the GNU Library General Public
  11. License along with this library; if not, write to the Free
  12. Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  13. MA 02111-1301, USA */
  14. #ifndef _ma_io_h_
  15. #define _ma_io_h_
  16. #ifdef HAVE_CURL
  17. #include <curl/curl.h>
  18. #endif
  19. enum enum_file_type {
  20. MA_FILE_NONE=0,
  21. MA_FILE_LOCAL=1,
  22. MA_FILE_REMOTE=2
  23. };
  24. typedef struct
  25. {
  26. enum enum_file_type type;
  27. void *ptr;
  28. } MA_FILE;
  29. #ifdef HAVE_REMOTEIO
  30. struct st_rio_methods {
  31. MA_FILE *(*mopen)(const char *url, const char *mode);
  32. int (*mclose)(MA_FILE *ptr);
  33. int (*mfeof)(MA_FILE *file);
  34. size_t (*mread)(void *ptr, size_t size, size_t nmemb, MA_FILE *file);
  35. char * (*mgets)(char *ptr, size_t size, MA_FILE *file);
  36. };
  37. #endif
  38. /* function prototypes */
  39. MA_FILE *ma_open(const char *location, const char *mode, MYSQL *mysql);
  40. int ma_close(MA_FILE *file);
  41. int ma_feof(MA_FILE *file);
  42. size_t ma_read(void *ptr, size_t size, size_t nmemb, MA_FILE *file);
  43. char *ma_gets(char *ptr, size_t size, MA_FILE *file);
  44. #endif