2018-07-21 03:51:49 +02:00
|
|
|
#ifndef NETWORK_H
|
|
|
|
#define NETWORK_H
|
2018-07-22 12:50:51 +02:00
|
|
|
|
2018-07-26 11:29:44 +02:00
|
|
|
#include "link.h"
|
|
|
|
|
2018-07-24 19:15:56 +02:00
|
|
|
#define CURL_MULTI_MAX_CONNECTION 20
|
2018-07-22 20:30:08 +02:00
|
|
|
|
2018-07-26 11:29:44 +02:00
|
|
|
typedef struct {
|
|
|
|
char *memory;
|
|
|
|
size_t size;
|
|
|
|
} MemoryStruct;
|
|
|
|
|
2018-07-22 20:30:08 +02:00
|
|
|
typedef enum {
|
2018-07-26 11:29:44 +02:00
|
|
|
FILESTAT = 's',
|
|
|
|
DATA = 'd'
|
|
|
|
} TransferType;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
TransferType type;
|
|
|
|
int transferring;
|
|
|
|
Link *link;
|
|
|
|
} TransferStruct;
|
|
|
|
|
|
|
|
/** \brief curl shared interface */
|
|
|
|
extern CURLSH *curl_share;
|
|
|
|
|
2018-07-26 11:58:51 +02:00
|
|
|
/** \brief perform one transfer cycle */
|
2018-07-26 11:29:44 +02:00
|
|
|
int curl_multi_perform_once();
|
2018-07-22 20:30:08 +02:00
|
|
|
|
2018-07-21 01:39:51 +02:00
|
|
|
/** \brief Initialise the network module */
|
2018-07-22 12:50:51 +02:00
|
|
|
void network_init(const char *url);
|
2018-07-21 01:39:51 +02:00
|
|
|
|
2018-07-26 11:58:51 +02:00
|
|
|
/** \brief blocking file transfer */
|
2018-07-26 11:29:44 +02:00
|
|
|
void transfer_blocking(CURL *curl);
|
2018-07-22 20:30:08 +02:00
|
|
|
|
2018-07-26 11:58:51 +02:00
|
|
|
/** \brief non blocking file transfer */
|
2018-07-26 11:29:44 +02:00
|
|
|
void transfer_nonblocking(CURL *curl);
|
2018-07-20 16:38:44 +02:00
|
|
|
|
2018-07-26 11:58:51 +02:00
|
|
|
/** \brief callback function for file transfer */
|
2018-07-26 11:29:44 +02:00
|
|
|
size_t
|
|
|
|
WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp);
|
2018-07-18 17:26:26 +02:00
|
|
|
|
|
|
|
#endif
|