ETVDB  0.6.0
ETVDB is a tool and a library to get data from The TV Database (TVDB)
etvdb_private.h
1 #ifndef __ETVDB_PRIVATE_H__
2 #define __ETVDB_PRIVATE_H__
3 
4 #include <stdlib.h>
5 #include <curl/curl.h>
6 #include <curl/easy.h>
7 #include "entities.h"
8 #include "etvdb.h"
9 
10 #ifndef UNUSED
11  #define UNUSED __attribute__((__unused__))
12 #endif
13 
14 #define CRIT(...) EINA_LOG_DOM_CRIT(_etvdb_log_dom, __VA_ARGS__)
15 #define ERR(...) EINA_LOG_DOM_ERR(_etvdb_log_dom, __VA_ARGS__)
16 #define INFO(...) EINA_LOG_DOM_INFO(_etvdb_log_dom, __VA_ARGS__)
17 #define WARN(...) EINA_LOG_DOM_WARN(_etvdb_log_dom, __VA_ARGS__)
18 #define DBG(...) EINA_LOG_DOM_DBG(_etvdb_log_dom, __VA_ARGS__)
19 
20 #define HTML2UTF(x, y) decode_html_entities_utf8(x, y)
21 
22 /* this copies a non-nul-terminated buffer and terminates It
23  * len is the size of src, dst has to be len+1 */
24 #define MEM2STR(dst, src, slen) \
25  memcpy(dst, src, slen); \
26  dst[slen] = '\0';
27 
28 /* convenience macro to compare a tag to unterminated input.
29  * it is meant to be used with eina simple_xml only. */
30 #define TAGCMP(s1, s2) \
31  memcmp(s1">", s2, strlen(s1">"))
32 
33 /* convenience macro to download a xml to memory
34  * use very carefully! dl.data has to bee free()d!
35  * the block following will be executed when the download fails. */
36 #define CURL_XML_DL_MEM(dl, uri) \
37  dl.data = malloc(1); \
38  dl.len = 0; \
39  curl_easy_setopt(curl_handle, CURLOPT_URL, uri); \
40  curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, 60); \
41  curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, _dl_to_mem_cb); \
42  curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&dl); \
43  if (curl_easy_perform(curl_handle))
44 
45 
46 #define ETVDB_API_KEY "A34C5A0CAF0F3EFD"
47 #define TVDB_API_URI "http://thetvdb.com/api"
48 
49 #ifndef DATA_LANG_FILE_XML
50  #define DATA_LANG_FILE_XML "../data/languages.xml"
51 #endif
52 
53 #ifndef URI_MAX
54  #define URI_MAX 4096
55 #endif
56 
57 /* eina logging domain for etvdb */
58 int _etvdb_log_dom;
59 
60 /* auxiliary variables for the xml parsers */
61 int _xml_count, _xml_depth, _xml_sibling;
62 CURL *curl_handle;
63 
65 typedef struct _download {
66  size_t len;
67  char *data;
68 } Download;
69 
71 typedef struct _pdata {
72  Series *s;
73  Eina_List *list;
75 
76 size_t _dl_to_mem_cb(char *ptr, size_t size, size_t nmemb, void *userdata);
77 
78 #endif /* __ETVDB_PRIVATE_H__ */
Series * s
Definition: etvdb_private.h:72
Definition: etvdb_private.h:65
Definition: etvdb.h:91
char * data
Definition: etvdb_private.h:67
Eina_List * list
Definition: etvdb_private.h:73
Definition: etvdb_private.h:71
This is the public etvdb API.
size_t len
Definition: etvdb_private.h:66