httpdirfs/network.h

62 lines
1.2 KiB
C
Raw Normal View History

2018-07-21 03:51:49 +02:00
#ifndef NETWORK_H
#define NETWORK_H
2018-07-22 12:50:51 +02:00
2018-07-24 19:15:56 +02:00
#include <stdlib.h>
2018-07-18 17:26:26 +02:00
#define URL_LEN_MAX 2048
#define LINK_LEN_MAX 255
2018-07-24 19:15:56 +02:00
#define CURL_MULTI_MAX_CONNECTION 20
/** \brief the link type */
typedef enum {
LINK_HEAD = 'H',
LINK_DIR = 'D',
LINK_FILE = 'F',
LINK_INVALID = '\0'
} LinkType;
/**
* \brief link table type
* \details index 0 contains the Link for the base URL
*/
typedef struct LinkTable LinkTable;
/** \brief link data type */
typedef struct Link Link;
struct Link {
char p_url[LINK_LEN_MAX];
char f_url[URL_LEN_MAX];
LinkType type;
size_t content_length;
LinkTable *next_table;
2018-07-24 07:44:41 +02:00
long time;
};
struct LinkTable {
int num;
Link **links;
};
/** \brief root link table */
extern LinkTable *ROOT_LINK_TBL;
/** \brief Initialise the network module */
2018-07-22 12:50:51 +02:00
void network_init(const char *url);
/**
* \brief download a link */
/* \return the number of bytes downloaded
*/
2018-07-24 08:23:44 +02:00
long path_download(const char *path, char *output_buf, size_t size,
2018-07-23 02:27:03 +02:00
off_t offset);
/** \brief create a new LinkTable */
LinkTable *LinkTable_new(const char *url);
2018-07-20 16:38:44 +02:00
2018-07-22 12:50:51 +02:00
/** \brief find the link associated with a path */
Link *path_to_Link(const char *path);
2018-07-18 17:26:26 +02:00
#endif