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