HowtoContributeCode: Cleanup
[quvi.git] / lib / internal.h
blobb0f41694fe1faf84d603889be9635527c8cb1823
1 /*
2 * Copyright (C) 2009,2010 Toni Gundogdu.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef internal_h
19 #define internal_h
21 #include <lua.h>
23 #include "platform.h"
24 #include "llst.h"
26 #define makelong(low,high) \
27 ((long) (((quvi_word)((uint64_t)(low) & 0xffff)) | \
28 ((uint64_t)((quvi_word)((uint64_t)(high) & 0xffff))) << 16))
30 #define makeword(low,high) \
31 ((quvi_word)(((quvi_byte)((uint64_t)(low) & 0xff)) | \
32 ((quvi_word)((quvi_byte) ((uint64_t)(high) & 0xff))) << 8))
34 #define _free(p) \
35 do { \
36 if (p) { free(p); p=0; } \
37 } while(0)
39 #define seterr(args...) \
40 do { \
41 _free(quvi->errmsg); \
42 asprintf(&quvi->errmsg, args); \
43 } while(0)
45 #define setvid(prop,args...) \
46 do { \
47 _free(prop); \
48 asprintf(&prop, args); \
49 } while(0)
51 #define csetopt(opt,param) \
52 curl_easy_setopt(quvi->curl,opt,param)
54 struct _quvi_s {
55 char *format;
56 int no_verify;
57 int no_shortened;
58 quvi_callback_status status_func;
59 quvi_callback_write write_func;
60 void *curl;
61 long httpcode;
62 long curlcode;
63 char *errmsg;
64 llst_node_t util_scripts;
65 llst_node_t website_scripts;
66 llst_node_t curr_next_host;
67 lua_State *lua;
70 typedef struct _quvi_s *_quvi_t;
72 struct _quvi_video_link_s {
73 char *url;
74 char *suffix;
75 char *content_type;
76 double length;
79 typedef struct _quvi_video_link_s *_quvi_video_link_t;
81 struct _quvi_video_s {
82 _quvi_t quvi;
83 char *id;
84 char *title;
85 char *starttime;
86 char *charset;
87 char *page_link;
88 llst_node_t link; /* holds all essential to video links */
89 llst_node_t curr; /* current (link) node */
90 char *host_id;
91 char *redirect;
94 typedef struct _quvi_video_s *_quvi_video_t;
96 struct _quvi_lua_script_s {
97 char *basename;
98 char *path;
101 typedef struct _quvi_lua_script_s *_quvi_lua_script_t;
103 #endif