2018-07-20 03:09:51 +02:00
|
|
|
#ifndef DATA_H
|
|
|
|
#define DATA_H
|
|
|
|
/**
|
|
|
|
* \file data.h
|
|
|
|
* \brief This header stores all the custom data type definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <curl/curl.h>
|
|
|
|
|
|
|
|
#define URL_LEN_MAX 2048
|
|
|
|
#define LINK_LEN_MAX 255
|
2018-07-20 16:38:44 +02:00
|
|
|
#define HTTP_OK 200
|
2018-07-20 03:09:51 +02:00
|
|
|
|
|
|
|
/** \brief the link type */
|
|
|
|
typedef enum {
|
2018-07-20 16:38:44 +02:00
|
|
|
LINK_HEAD = 'H',
|
2018-07-20 03:09:51 +02:00
|
|
|
LINK_DIR = 'D',
|
|
|
|
LINK_FILE = 'F',
|
2018-07-20 16:38:44 +02:00
|
|
|
LINK_UNKNOWN = 'U',
|
|
|
|
LINK_INVALID = 'I'
|
2018-07-20 03:09:51 +02:00
|
|
|
} LinkType;
|
|
|
|
|
2018-07-22 05:26:22 +02:00
|
|
|
/**
|
|
|
|
* \brief link table type
|
|
|
|
* \details index 0 contains the Link for the base URL
|
|
|
|
*/
|
|
|
|
typedef struct LinkTable LinkTable;
|
|
|
|
|
2018-07-20 03:09:51 +02:00
|
|
|
/** \brief link data type */
|
2018-07-22 05:26:22 +02:00
|
|
|
typedef struct Link Link;
|
|
|
|
|
2018-07-22 14:35:11 +02:00
|
|
|
/** \brief root link table */
|
|
|
|
extern LinkTable *ROOT_LINK_TBL;
|
|
|
|
|
2018-07-22 05:26:22 +02:00
|
|
|
struct Link {
|
2018-07-22 12:50:51 +02:00
|
|
|
char p_url[LINK_LEN_MAX];
|
|
|
|
char f_url[URL_LEN_MAX];
|
2018-07-20 03:09:51 +02:00
|
|
|
LinkType type;
|
2018-07-20 14:59:25 +02:00
|
|
|
CURL *curl;
|
|
|
|
char *body;
|
|
|
|
size_t body_sz;
|
|
|
|
size_t content_length;
|
2018-07-22 12:50:51 +02:00
|
|
|
LinkTable *next_table;
|
2018-07-22 05:26:22 +02:00
|
|
|
};
|
2018-07-20 03:09:51 +02:00
|
|
|
|
2018-07-22 05:26:22 +02:00
|
|
|
struct LinkTable {
|
2018-07-20 03:09:51 +02:00
|
|
|
int num;
|
|
|
|
Link **links;
|
2018-07-22 05:26:22 +02:00
|
|
|
};
|
|
|
|
|
2018-07-20 03:09:51 +02:00
|
|
|
#endif
|