| 1 |
|
| 2 |
|
| 3 |
#ifndef _FOPEN_H_INCLUDED |
| 4 |
#define _FOPEN_H_INCLUDED |
| 5 |
|
| 6 |
#include <stdio.h> |
| 7 |
#include <curl/curl.h> |
| 8 |
|
| 9 |
enum fcurl_type_e { |
| 10 |
CFTYPE_NONE=0, |
| 11 |
CFTYPE_FILE=1, |
| 12 |
CFTYPE_CURL=2 |
| 13 |
}; |
| 14 |
|
| 15 |
struct fcurl_data |
| 16 |
{ |
| 17 |
enum fcurl_type_e type; |
| 18 |
union { |
| 19 |
CURL *curl; |
| 20 |
FILE *file; |
| 21 |
} handle; |
| 22 |
|
| 23 |
char *buffer; |
| 24 |
size_t buffer_len; |
| 25 |
size_t buffer_pos; |
| 26 |
int still_running; |
| 27 |
}; |
| 28 |
|
| 29 |
typedef struct fcurl_data URL_FILE; |
| 30 |
|
| 31 |
|
| 32 |
URL_FILE *url_fopen(const char *url,const char *operation); |
| 33 |
int url_fclose(URL_FILE *file); |
| 34 |
int url_feof(URL_FILE *file); |
| 35 |
size_t url_fread(void *ptr, size_t size, size_t nmemb, URL_FILE *file); |
| 36 |
char * url_fgets(char *ptr, size_t size, URL_FILE *file); |
| 37 |
void url_rewind(URL_FILE *file); |
| 38 |
|
| 39 |
#endif |