*
*/
void
-ajax_generate_select_functions(tcp_queue_t *tq, const char *fprefix,
+ajax_generate_select_functions(htsbuf_queue_t *hq, const char *fprefix,
char **selvector)
{
int n;
- tcp_qprintf(tq, "<script type=\"text/javascript\">\r\n"
+ htsbuf_qprintf(hq, "<script type=\"text/javascript\">\r\n"
"//<![CDATA[\r\n");
/* Select all */
- tcp_qprintf(tq, "%s_sel_all = function() {\r\n", fprefix);
+ htsbuf_qprintf(hq, "%s_sel_all = function() {\r\n", fprefix);
for(n = 0; selvector[n] != NULL; n++)
- tcp_qprintf(tq, "$('sel_%s').checked = true;\r\n", selvector[n]);
- tcp_qprintf(tq, "}\r\n");
+ htsbuf_qprintf(hq, "$('sel_%s').checked = true;\r\n", selvector[n]);
+ htsbuf_qprintf(hq, "}\r\n");
/* Select none */
- tcp_qprintf(tq, "%s_sel_none = function() {\r\n", fprefix);
+ htsbuf_qprintf(hq, "%s_sel_none = function() {\r\n", fprefix);
for(n = 0; selvector[n] != NULL; n++)
- tcp_qprintf(tq, "$('sel_%s').checked = false;\r\n", selvector[n]);
- tcp_qprintf(tq, "}\r\n");
+ htsbuf_qprintf(hq, "$('sel_%s').checked = false;\r\n", selvector[n]);
+ htsbuf_qprintf(hq, "}\r\n");
/* Invert selection */
- tcp_qprintf(tq, "%s_sel_invert = function() {\r\n", fprefix);
+ htsbuf_qprintf(hq, "%s_sel_invert = function() {\r\n", fprefix);
for(n = 0; selvector[n] != NULL; n++)
- tcp_qprintf(tq, "$('sel_%s').checked = !$('sel_%s').checked;\r\n",
+ htsbuf_qprintf(hq, "$('sel_%s').checked = !$('sel_%s').checked;\r\n",
selvector[n], selvector[n]);
- tcp_qprintf(tq, "}\r\n");
+ htsbuf_qprintf(hq, "}\r\n");
/* Invoke AJAX call containing all selected elements */
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"%s_sel_do = function(op, arg1, arg2, check) {\r\n"
"if(check == true && !confirm(\"Are you sure?\")) {return;}\r\n"
"var h = new Hash();\r\n"
);
for(n = 0; selvector[n] != NULL; n++)
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"if($('sel_%s').checked) {h.set('%s', 'selected') }\r\n",
selvector[n], selvector[n]);
- tcp_qprintf(tq, " new Ajax.Request('/ajax/' + op, "
+ htsbuf_qprintf(hq, " new Ajax.Request('/ajax/' + op, "
"{parameters: h});\r\n");
- tcp_qprintf(tq, "}\r\n");
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq, "}\r\n");
+ htsbuf_qprintf(hq,
"\r\n//]]>\r\n"
"</script>\r\n");
}
* AJAX table
*/
void
-ajax_table_top(ajax_table_t *t, http_connection_t *hc, tcp_queue_t *tq,
+ajax_table_top(ajax_table_t *t, http_connection_t *hc, htsbuf_queue_t *hq,
const char *names[], int weights[])
{
int n = 0, i, tw = 0;
memset(t, 0, sizeof(ajax_table_t));
- t->tq = tq;
+ t->hq = hq;
for(i = 0; i < n; i++)
t->csize[i] = 100 * weights[i] / tw;
- tcp_qprintf(tq, "<div style=\"padding-right: 20px\">");
+ htsbuf_qprintf(hq, "<div style=\"padding-right: 20px\">");
- tcp_qprintf(tq, "<div style=\"overflow: auto; width: 100%%\">");
+ htsbuf_qprintf(hq, "<div style=\"overflow: auto; width: 100%%\">");
for(i = 0; i < n; i++)
- tcp_qprintf(tq, "<div style=\"float: left; width: %d%%\">%s</div>",
+ htsbuf_qprintf(hq, "<div style=\"float: left; width: %d%%\">%s</div>",
t->csize[i], *names[i] ? names[i]: " ");
- tcp_qprintf(tq, "</div></div><hr><div class=\"normaltable\">\r\n");
+ htsbuf_qprintf(hq, "</div></div><hr><div class=\"normaltable\">\r\n");
}
/**
{
t->rowid = id;
t->rowcol = !t->rowcol;
- tcp_qprintf(t->tq, "%s<div style=\"%soverflow: auto; width: 100%\">",
+ htsbuf_qprintf(t->hq, "%s<div style=\"%soverflow: auto; width: 100%\">",
t->inrow ? "</div>\r\n" : "",
t->rowcol ? "background: #fff; " : "");
t->inrow = 1;
void
ajax_table_subrow_start(ajax_table_t *t)
{
- tcp_qprintf(t->tq, "<div style=\"overflow: auto; width: 100%\">");
+ htsbuf_qprintf(t->hq, "<div style=\"overflow: auto; width: 100%\">");
t->curcol = 0;
}
void
ajax_table_subrow_end(ajax_table_t *t)
{
- tcp_qprintf(t->tq, "</div>");
+ htsbuf_qprintf(t->hq, "</div>");
t->curcol = 0;
}
assert(t->inrow == 1);
t->inrow = 0;
/* Extra info */
- tcp_qprintf(t->tq, "</div><div id=\"details_%s\" style=\"%sdisplay: none\">",
+ htsbuf_qprintf(t->hq, "</div><div id=\"details_%s\" style=\"%sdisplay: none\">",
t->rowid, t->rowcol ? "background: #fff; " : "");
}
ajax_table_details_end(ajax_table_t *t)
{
/* Extra info */
- tcp_qprintf(t->tq, "</div>");
+ htsbuf_qprintf(t->hq, "</div>");
}
va_start(ap, fmt);
if(t->rowid && id) {
- tcp_qprintf(t->tq, "<div id=\"%s_%s\"", id, t->rowid);
+ htsbuf_qprintf(t->hq, "<div id=\"%s_%s\"", id, t->rowid);
} else {
- tcp_qprintf(t->tq, "<div");
+ htsbuf_qprintf(t->hq, "<div");
}
- tcp_qprintf(t->tq,
+ htsbuf_qprintf(t->hq,
" style=\"float: left; width: %d%%\">", t->csize[t->curcol]);
t->curcol++;
if(t->curcol == 20)
abort();
if(fmt == NULL)
- tcp_qprintf(t->tq, " ");
+ htsbuf_qprintf(t->hq, " ");
else
- tcp_qvprintf(t->tq, fmt, ap);
+ htsbuf_vqprintf(t->hq, fmt, ap);
va_end(ap);
- tcp_qprintf(t->tq, "</div>");
+ htsbuf_qprintf(t->hq, "</div>");
}
/**
void
ajax_table_bottom(ajax_table_t *t)
{
- tcp_qprintf(t->tq, "%s</div>", t->inrow ? "</div>" : "");
+ htsbuf_qprintf(t->hq, "%s</div>", t->inrow ? "</div>" : "");
}
/**
* AJAX box start
*/
void
-ajax_box_begin(tcp_queue_t *tq, ajax_box_t type,
+ajax_box_begin(htsbuf_queue_t *hq, ajax_box_t type,
const char *id, const char *style, const char *title)
{
char id0[100], style0[100];
switch(type) {
case AJAX_BOX_SIDEBOX:
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"<div class=\"sidebox\">"
"<div class=\"boxhead\"><h2>%s</h2></div>\r\n"
" <div class=\"boxbody\" %s%s>",
break;
case AJAX_BOX_FILLED:
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"<div style=\"margin: 3px\">"
"<b class=\"filledbox\">"
"<b class=\"filledbox1\"><b></b></b>"
break;
case AJAX_BOX_BORDER:
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"<div style=\"margin: 3px\">"
"<b class=\"borderbox\">"
"<b class=\"borderbox1\"><b></b></b>"
* AJAX box end
*/
void
-ajax_box_end(tcp_queue_t *tq, ajax_box_t type)
+ajax_box_end(htsbuf_queue_t *hq, ajax_box_t type)
{
switch(type) {
case AJAX_BOX_SIDEBOX:
- tcp_qprintf(tq,"</div></div>");
+ htsbuf_qprintf(hq,"</div></div>");
break;
case AJAX_BOX_FILLED:
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"</div>"
"<b class=\"filledbox\">"
"<b class=\"filledbox5\"></b>"
break;
case AJAX_BOX_BORDER:
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"</div>"
"<b class=\"borderbox\">"
"<b class=\"borderbox3\"></b>"
*
*/
void
-ajax_js(tcp_queue_t *tq, const char *fmt, ...)
+ajax_js(htsbuf_queue_t *hq, const char *fmt, ...)
{
va_list ap;
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"<script type=\"text/javascript\">\r\n"
"//<![CDATA[\r\n");
va_start(ap, fmt);
- tcp_qvprintf(tq, fmt, ap);
+ htsbuf_vqprintf(hq, fmt, ap);
va_end(ap);
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"\r\n//]]>\r\n"
"</script>\r\n");
}
* Based on the given char[] array, generate a menu bar
*/
void
-ajax_menu_bar_from_array(tcp_queue_t *tq, const char *name,
+ajax_menu_bar_from_array(htsbuf_queue_t *hq, const char *name,
const char **vec, int num, int cur)
{
int i;
- tcp_qprintf(tq, "<ul class=\"menubar\">");
+ htsbuf_qprintf(hq, "<ul class=\"menubar\">");
for(i = 0; i < num; i++) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"<li%s>"
"<a href=\"javascript:switchtab('%s', '%d')\">%s</a>"
"</li>",
cur == i ? " style=\"font-weight:bold;\"" : "", name,
i, vec[i]);
}
- tcp_qprintf(tq, "</ul>");
+ htsbuf_qprintf(hq, "</ul>");
}
*
*/
void
-ajax_a_jsfuncf(tcp_queue_t *tq, const char *innerhtml, const char *fmt, ...)
+ajax_a_jsfuncf(htsbuf_queue_t *hq, const char *innerhtml, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- tcp_qprintf(tq, "<a href=\"javascript:void(0)\" onClick=\"javascript:");
- tcp_qvprintf(tq, fmt, ap);
- tcp_qprintf(tq, "\">%s</a>", innerhtml);
+ htsbuf_qprintf(hq, "<a href=\"javascript:void(0)\" onClick=\"javascript:");
+ htsbuf_vqprintf(hq, fmt, ap);
+ htsbuf_qprintf(hq, "\">%s</a>", innerhtml);
}
/**
*
*/
void
-ajax_button(tcp_queue_t *tq, const char *caption, const char *code, ...)
+ajax_button(htsbuf_queue_t *hq, const char *caption, const char *code, ...)
{
va_list ap;
va_start(ap, code);
- tcp_qprintf(tq, "<input type=\"button\" value=\"%s\" onClick=\"",
+ htsbuf_qprintf(hq, "<input type=\"button\" value=\"%s\" onClick=\"",
caption);
- tcp_qvprintf(tq, code, ap);
- tcp_qprintf(tq, "\">");
+ htsbuf_vqprintf(hq, code, ap);
+ htsbuf_qprintf(hq, "\">");
}
if(remain == NULL)
return HTTP_STATUS_NOT_FOUND;
- ajax_menu_bar_from_array(&hr->hr_tq, "top",
+ ajax_menu_bar_from_array(&hr->hr_q, "top",
ajax_tabnames, AJAX_TABS, atoi(remain));
http_output_html(hc, hr);
return 0;
static int
ajax_about_tab(http_connection_t *hc, http_reply_t *hr)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *hq = &hr->hr_q;
- tcp_qprintf(tq, "<center>");
- tcp_qprintf(tq, "<div style=\"padding: auto; width: 400px\">");
+ htsbuf_qprintf(hq, "<center>");
+ htsbuf_qprintf(hq, "<div style=\"padding: auto; width: 400px\">");
- ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, "About");
+ ajax_box_begin(hq, AJAX_BOX_SIDEBOX, NULL, NULL, "About");
- tcp_qprintf(tq, "<div style=\"text-align: center\">");
+ htsbuf_qprintf(hq, "<div style=\"text-align: center\">");
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"<p>HTS / Tvheadend</p>"
"<p>(c) 2006-2008 Andreas \303\226man</p>"
"<p>Latest release and information is available at:</p>"
"<p><a href=\"http://www.ffmpeg.org/\">FFmpeg</a></p>"
);
- tcp_qprintf(tq, "</div>");
- ajax_box_end(tq, AJAX_BOX_SIDEBOX);
- tcp_qprintf(tq, "</div>");
- tcp_qprintf(tq, "</center>");
+ htsbuf_qprintf(hq, "</div>");
+ ajax_box_end(hq, AJAX_BOX_SIDEBOX);
+ htsbuf_qprintf(hq, "</div>");
+ htsbuf_qprintf(hq, "</center>");
http_output_html(hc, hr);
return 0;
ajax_page_root(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *hq = &hr->hr_q;
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\r\n"
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
/*
"<body>");
- tcp_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
+ htsbuf_qprintf(hq, "<div style=\"overflow: auto; width: 100%\">");
- tcp_qprintf(tq, "<div style=\"float: left; width: 100%\">");
+ htsbuf_qprintf(hq, "<div style=\"float: left; width: 100%\">");
- ajax_box_begin(tq, AJAX_BOX_FILLED, NULL, NULL, NULL);
+ ajax_box_begin(hq, AJAX_BOX_FILLED, NULL, NULL, NULL);
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"<div style=\"width: 100%%; overflow: hidden\">"
"<div style=\"float: left; width: 30%%\">"
"Tvheadend (%s)"
"</div>",
htsversion);
- ajax_mailbox_start(tq);
+ ajax_mailbox_start(hq);
- ajax_box_end(tq, AJAX_BOX_FILLED);
+ ajax_box_end(hq, AJAX_BOX_FILLED);
- tcp_qprintf(tq, "<div id=\"topdeck\"></div>");
+ htsbuf_qprintf(hq, "<div id=\"topdeck\"></div>");
- ajax_js(tq, "switchtab('top', '0')");
+ ajax_js(hq, "switchtab('top', '0')");
#if 0
- tcp_qprintf(tq, "</div><div style=\"float: left; width: 20%\">");
+ htsbuf_qprintf(hq, "</div><div style=\"float: left; width: 20%\">");
- ajax_box_begin(tq, AJAX_BOX_SIDEBOX, "statusbox", NULL, "System status");
- ajax_box_end(tq, AJAX_BOX_SIDEBOX);
+ ajax_box_begin(hq, AJAX_BOX_SIDEBOX, "statusbox", NULL, "System status");
+ ajax_box_end(hq, AJAX_BOX_SIDEBOX);
#endif
- tcp_qprintf(tq, "</div></div></body></html>");
+ htsbuf_qprintf(hq, "</div></div></body></html>");
http_output_html(hc, hr);
return 0;
} ajax_box_t;
-void ajax_box_begin(tcp_queue_t *tq, ajax_box_t type,
+void ajax_box_begin(htsbuf_queue_t *q, ajax_box_t type,
const char *id, const char *style, const char *title);
-void ajax_box_end(tcp_queue_t *tq, ajax_box_t type);
+void ajax_box_end(htsbuf_queue_t *q, ajax_box_t type);
const char *rowid;
int csize[20];
- tcp_queue_t *tq;
+ htsbuf_queue_t *hq;
int rowcol;
} ajax_table_t;
-void ajax_table_top(ajax_table_t *t, http_connection_t *hc, tcp_queue_t *tq,
+void ajax_table_top(ajax_table_t *t, http_connection_t *hc, htsbuf_queue_t *q,
const char *names[], int weights[]);
void ajax_table_row_start(ajax_table_t *t, const char *id);
void ajax_table_cell(ajax_table_t *t, const char *id, const char *fmt, ...);
-void ajax_js(tcp_queue_t *tq, const char *fmt, ...);
+void ajax_js(htsbuf_queue_t *q, const char *fmt, ...);
TAILQ_HEAD(ajax_menu_entry_queue, ajax_menu_entry);
void ajax_channels_init(void);
void ajax_config_init(void);
-void ajax_menu_bar_from_array(tcp_queue_t *tq, const char *name,
+void ajax_menu_bar_from_array(htsbuf_queue_t *q, const char *name,
const char **vec, int num, int cur);
int ajax_channelgroup_tab(http_connection_t *hc, http_reply_t *hr);
void ajax_config_transport_init(void);
-int ajax_transport_build_list(http_connection_t *hc, tcp_queue_t *tq,
+int ajax_transport_build_list(http_connection_t *hc, htsbuf_queue_t *q,
struct th_transport_tree *tlist,
int ntransports);
const char *ajaxui_escape_apostrophe(const char *content);
-void ajax_generate_select_functions(tcp_queue_t *tq, const char *fprefix,
+void ajax_generate_select_functions(htsbuf_queue_t *q, const char *fprefix,
char **selvector);
-void ajax_a_jsfuncf(tcp_queue_t *tq, const char *innerhtml,
+void ajax_a_jsfuncf(htsbuf_queue_t *q, const char *innerhtml,
const char *fmt, ...);
-void ajax_button(tcp_queue_t *tq, const char *caption, const char *code, ...);
+void ajax_button(htsbuf_queue_t *q,
+ const char *caption, const char *code, ...);
void ajax_transport_build_mapper_state(char *buf, size_t siz,
th_transport_t *t, int mapped);
#include "epg.h"
static void
-ajax_channelgroupmenu_content(tcp_queue_t *tq, int current)
+ajax_channelgroupmenu_content(htsbuf_queue_t *tq, int current)
{
channel_group_t *tcg;
- tcp_qprintf(tq, "<ul class=\"menubar\">");
+ htsbuf_qprintf(tq, "<ul class=\"menubar\">");
TAILQ_FOREACH(tcg, &all_channel_groups, tcg_global_link) {
if(tcg->tcg_hidden)
if(current < 1)
current = tcg->tcg_tag;
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<li%s>"
"<a href=\"javascript:switchtab('channelgroup', '%d')\">%s</a>"
"</li>",
current == tcg->tcg_tag ? " style=\"font-weight:bold;\"" : "",
tcg->tcg_tag, tcg->tcg_name);
}
- tcp_qprintf(tq, "</ul>");
+ htsbuf_qprintf(tq, "</ul>");
}
ajax_channelgroup_menu(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
if(remain == NULL)
return HTTP_STATUS_NOT_FOUND;
static void
-ajax_output_event(tcp_queue_t *tq, event_t *e, int flags, int color)
+ajax_output_event(htsbuf_queue_t *tq, event_t *e, int flags, int color)
{
struct tm a, b;
time_t stop;
- tcp_qprintf(tq, "<div class=\"fullrow\"%s>",
+ htsbuf_qprintf(tq, "<div class=\"fullrow\"%s>",
color ? "style=\"background: #fff\" " : "");
localtime_r(&e->e_start, &a);
stop = e->e_start + e->e_duration;
localtime_r(&stop, &b);
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div class=\"compact\" style=\"width: 35%%\">"
"%02d:%02d-%02d:%02d"
"</div>",
a.tm_hour, a.tm_min, b.tm_hour, b.tm_min);
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div class=\"compact\" style=\"width: 65%%\">"
"%s"
"</div>",
e->e_title);
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</div>");
}
static void
-ajax_list_events(tcp_queue_t *tq, channel_t *ch, int lines)
+ajax_list_events(htsbuf_queue_t *tq, channel_t *ch, int lines)
{
event_t *e;
int i;
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
channel_t *ch;
channel_group_t *tcg;
char dispname[20];
nchs++;
- tcp_qprintf(tq, "<div style=\"float:left; width: 25%%\">");
+ htsbuf_qprintf(tq, "<div style=\"float:left; width: 25%%\">");
snprintf(dispname, sizeof(dispname), "%s", ch->ch_name);
strcpy(dispname + sizeof(dispname) - 4, "...");
/* inner */
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div style=\"width: 100%%; overflow: hidden; height:36px\">");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div style=\"float: left; height:32px; width:32px; "
"margin: 2px\">");
if(ch->ch_icon != NULL) {
- tcp_qprintf(tq, "<img src=\"%s\" style=\"width:32px\">",
+ htsbuf_qprintf(tq, "<img src=\"%s\" style=\"width:32px\">",
ch->ch_icon);
}
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</div>");
- tcp_qprintf(tq, "<div style=\"float:left; text-align: right\">");
+ htsbuf_qprintf(tq, "<div style=\"float:left; text-align: right\">");
si = (struct sockaddr_in *)&hc->hc_tcp_session.tcp_self_addr;
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<a href=\"rtsp://%s:%d/%s\">Stream</a>",
inet_ntoa(si->sin_addr), ntohs(si->sin_port),
ch->ch_sname);
- tcp_qprintf(tq, "</div>");
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</div>");
- tcp_qprintf(tq, "<div id=\"events%d\" style=\"height:42px\">", ch->ch_tag);
+ htsbuf_qprintf(tq, "<div id=\"events%d\" style=\"height:42px\">", ch->ch_tag);
ajax_list_events(tq, ch, 3);
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</div>");
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</div>");
}
if(nchs == 0)
- tcp_qprintf(tq, "<div style=\"text-align: center; font-weight: bold\">"
+ htsbuf_qprintf(tq, "<div style=\"text-align: center; font-weight: bold\">"
"No channels in this group</div>");
http_output_html(hc, hr);
int
ajax_channelgroup_tab(http_connection_t *hc, http_reply_t *hr)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
ajax_box_begin(tq, AJAX_BOX_FILLED, "channelgroupmenu", NULL, NULL);
ajax_box_end(tq, AJAX_BOX_FILLED);
- tcp_qprintf(tq, "<div id=\"channelgroupdeck\"></div>");
+ htsbuf_qprintf(tq, "<div id=\"channelgroupdeck\"></div>");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<script type=\"text/javascript\">"
"switchtab('channelgroup', '0')"
"</script>");
ajax_config_menu(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
if(remain == NULL)
return HTTP_STATUS_NOT_FOUND;
int
ajax_config_tab(http_connection_t *hc, http_reply_t *hr)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
ajax_box_begin(tq, AJAX_BOX_FILLED, "configmenu", NULL, NULL);
ajax_box_end(tq, AJAX_BOX_FILLED);
- tcp_qprintf(tq, "<div id=\"configdeck\"></div>");
+ htsbuf_qprintf(tq, "<div id=\"configdeck\"></div>");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<script type=\"text/javascript\">"
"switchtab('config', '0')"
"</script>");
-
+
http_output_html(hc, hr);
return 0;
}
int
ajax_config_access_tab(http_connection_t *hc, http_reply_t *hr)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
if(access_verify(hc->hc_username, hc->hc_password,
(struct sockaddr *)&hc->hc_tcp_session.tcp_peer_addr,
AJAX_ACCESS_ACCESSCTRL))
return HTTP_STATUS_UNAUTHORIZED;
- tcp_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
+ htsbuf_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, "Access control");
- tcp_qprintf(tq, "<div id=\"alist\"></div>");
+ htsbuf_qprintf(tq, "<div id=\"alist\"></div>");
ajax_js(tq,
"new Ajax.Updater('alist', '/ajax/accesslist', "
"{method: 'get', evalScripts: true});");
- tcp_qprintf(tq, "<hr><div style=\"overflow: auto; width: 100%\">");
+ htsbuf_qprintf(tq, "<hr><div style=\"overflow: auto; width: 100%\">");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div style=\"height: 20px;\">"
"<div style=\"float: left; margin-right: 4px\">"
"<input type=\"text\" id=\"newuser\">"
"</div>"
"</div>");
- tcp_qprintf(tq, "</div>\r\n");
+ htsbuf_qprintf(tq, "</div>\r\n");
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</div>");
http_output_html(hc, hr);
return 0;
}
ajax_accesslist(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
access_entry_t *ae;
ajax_table_t ta;
char id[100];
ajax_accessadd(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
access_entry_t *ae;
const char *t;
if((t = http_arg_get(&hc->hc_req_args, "name")) == NULL)
return HTTP_STATUS_BAD_REQUEST;
- tcp_qprintf(tq, "$('newuser').clear();\r\n");
+ htsbuf_qprintf(tq, "$('newuser').clear();\r\n");
if(t == NULL || strlen(t) < 1 || strchr(t, '\'') || strchr(t, '"')) {
- tcp_qprintf(tq, "alert('Invalid username');\r\n");
+ htsbuf_qprintf(tq, "alert('Invalid username');\r\n");
} else {
ae = access_add(t);
if(ae == NULL) {
- tcp_qprintf(tq, "alert('Invalid prefix');\r\n");
+ htsbuf_qprintf(tq, "alert('Invalid prefix');\r\n");
} else {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"new Ajax.Updater('alist', '/ajax/accesslist', "
"{method: 'get', evalScripts: true});\r\n");
}
ajax_accesschange(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- // tcp_queue_t *tq = &hr->hr_tq;
+ // htsbuf_queue_t *tq = &hr->hr_tq;
access_entry_t *ae;
const char *e, *c;
int bit;
ajax_accessdel(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
access_entry_t *ae;
const char *e;
access_delete(ae);
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"new Ajax.Updater('alist', '/ajax/accesslist', "
"{method: 'get', evalScripts: true});\r\n");
ajax_accesssetpw(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
access_entry_t *ae;
const char *e;
access_save();
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"$('password_%d').innerHTML= '"
"<a href=\"javascript:void(0)\" "
"onClick=\"makedivinput(\\'password_%d\\', "
* Render a channel group widget
*/
static void
-ajax_chgroup_build(tcp_queue_t *tq, channel_group_t *tcg)
+ajax_chgroup_build(htsbuf_queue_t *tq, channel_group_t *tcg)
{
- tcp_qprintf(tq, "<li id=\"chgrp_%d\">", tcg->tcg_tag);
+ htsbuf_qprintf(tq, "<li id=\"chgrp_%d\">", tcg->tcg_tag);
ajax_box_begin(tq, AJAX_BOX_BORDER, NULL, NULL, NULL);
- tcp_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
+ htsbuf_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div style=\"float: left; width: 60%\">"
"<a href=\"javascript:void(0)\" "
"onClick=\"$('cheditortab').innerHTML=''; "
if(tcg != defgroup) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div style=\"float: left; width: 40%\" "
"class=\"chgroupaction\">"
"<a href=\"javascript:void(0)\" "
}
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</div>");
ajax_box_end(tq, AJAX_BOX_BORDER);
- tcp_qprintf(tq, "</li>");
+ htsbuf_qprintf(tq, "</li>");
}
/**
const char *remain, void *opaque)
{
channel_group_t *tcg;
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
http_arg_t *ra;
TAILQ_FOREACH(ra, &hc->hc_req_args, link) {
channel_group_settings_write();
- tcp_qprintf(tq, "<span id=\"updatedok\">Updated on server</span>");
+ htsbuf_qprintf(tq, "<span id=\"updatedok\">Updated on server</span>");
ajax_js(tq, "Effect.Fade('updatedok')");
http_output_html(hc, hr);
return 0;
const char *remain, void *opaque)
{
channel_group_t *tcg;
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
const char *name;
if((name = http_arg_get(&hc->hc_req_args, "name")) != NULL) {
const char *remain, void *opaque)
{
channel_group_t *tcg;
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
const char *id;
if((id = http_arg_get(&hc->hc_req_args, "id")) == NULL)
if((tcg = channel_group_by_tag(atoi(id))) == NULL)
return HTTP_STATUS_BAD_REQUEST;
- tcp_qprintf(tq, "$('chgrp_%d').remove();", tcg->tcg_tag);
+ htsbuf_qprintf(tq, "$('chgrp_%d').remove();", tcg->tcg_tag);
http_output(hc, hr, "text/javascript; charset=UTF-8", NULL, 0);
channel_group_destroy(tcg);
int
ajax_config_channels_tab(http_connection_t *hc, http_reply_t *hr)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
channel_group_t *tcg;
- tcp_qprintf(tq, "<div style=\"float: left; width: 30%\">");
+ htsbuf_qprintf(tq, "<div style=\"float: left; width: 30%\">");
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, "channelgroups",
NULL, "Channel groups");
- tcp_qprintf(tq, "<div style=\"height:15px; text-align:center\" "
+ htsbuf_qprintf(tq, "<div style=\"height:15px; text-align:center\" "
"id=\"list-info\"></div>");
- tcp_qprintf(tq, "<ul id=\"channelgrouplist\" class=\"draglist\">");
+ htsbuf_qprintf(tq, "<ul id=\"channelgrouplist\" class=\"draglist\">");
TAILQ_FOREACH(tcg, &all_channel_groups, tcg_global_link) {
if(tcg->tcg_hidden)
ajax_chgroup_build(tq, tcg);
}
- tcp_qprintf(tq, "</ul>");
+ htsbuf_qprintf(tq, "</ul>");
ajax_js(tq, "Sortable.create(\"channelgrouplist\", "
"{onUpdate:function(){updatelistonserver("
* Add new group
*/
- tcp_qprintf(tq, "<hr>");
+ htsbuf_qprintf(tq, "<hr>");
ajax_box_begin(tq, AJAX_BOX_BORDER, NULL, NULL, NULL);
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div style=\"height: 25px\">"
"<div style=\"float: left\">"
"<input type=\"text\" id=\"newchgrp\">"
ajax_box_end(tq, AJAX_BOX_BORDER);
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</div>");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div id=\"groupeditortab\" "
"style=\"overflow: auto; float: left; width: 30%\"></div>");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div id=\"cheditortab\" "
"style=\"overflow: auto; float: left; width: 40%\"></div>");
ajax_chgroup_editor(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
channel_t *ch;
channel_group_t *tcg, *tcg2;
th_transport_t *t;
if(remain == NULL || (tcg = channel_group_by_tag(atoi(remain))) == NULL)
return HTTP_STATUS_BAD_REQUEST;
- tcp_qprintf(tq, "<script type=\"text/javascript\">\r\n"
+ htsbuf_qprintf(tq, "<script type=\"text/javascript\">\r\n"
"//<![CDATA[\r\n");
/* Select all */
- tcp_qprintf(tq, "select_all = function() {\r\n");
+ htsbuf_qprintf(tq, "select_all = function() {\r\n");
TAILQ_FOREACH(ch, &tcg->tcg_channels, ch_group_link) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"$('sel_%d').checked = true;\r\n",
ch->ch_tag);
}
- tcp_qprintf(tq, "}\r\n");
+ htsbuf_qprintf(tq, "}\r\n");
/* Select none */
- tcp_qprintf(tq, "select_none = function() {\r\n");
+ htsbuf_qprintf(tq, "select_none = function() {\r\n");
TAILQ_FOREACH(ch, &tcg->tcg_channels, ch_group_link) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"$('sel_%d').checked = false;\r\n",
ch->ch_tag);
}
- tcp_qprintf(tq, "}\r\n");
+ htsbuf_qprintf(tq, "}\r\n");
/* Invert selection */
- tcp_qprintf(tq, "select_invert = function() {\r\n");
+ htsbuf_qprintf(tq, "select_invert = function() {\r\n");
TAILQ_FOREACH(ch, &tcg->tcg_channels, ch_group_link) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"$('sel_%d').checked = !$('sel_%d').checked;\r\n",
ch->ch_tag, ch->ch_tag);
}
- tcp_qprintf(tq, "}\r\n");
+ htsbuf_qprintf(tq, "}\r\n");
/* Invert selection */
- tcp_qprintf(tq, "select_sources = function() {\r\n");
+ htsbuf_qprintf(tq, "select_sources = function() {\r\n");
TAILQ_FOREACH(ch, &tcg->tcg_channels, ch_group_link) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"$('sel_%d').checked = %s;\r\n",
ch->ch_tag, LIST_FIRST(&ch->ch_transports) ? "true" : "false");
}
- tcp_qprintf(tq, "}\r\n");
+ htsbuf_qprintf(tq, "}\r\n");
/* Invoke AJAX call containing all selected elements */
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"select_do = function(op, arg1, arg2, check) {\r\n"
"if(check == true && !confirm(\"Are you sure?\")) {return;}\r\n"
"var h = new Hash();\r\n"
);
TAILQ_FOREACH(ch, &tcg->tcg_channels, ch_group_link) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"if($('sel_%d').checked) {h.set('%d', 'selected') }\r\n",
ch->ch_tag, ch->ch_tag);
}
- tcp_qprintf(tq, " new Ajax.Request('/ajax/chop/' + op, "
+ htsbuf_qprintf(tq, " new Ajax.Request('/ajax/chop/' + op, "
"{parameters: h});\r\n");
- tcp_qprintf(tq, "}\r\n");
+ htsbuf_qprintf(tq, "}\r\n");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"\r\n//]]>\r\n"
"</script>\r\n");
}
ajax_table_bottom(&ta);
- tcp_qprintf(tq, "<hr>\r\n");
- tcp_qprintf(tq, "<div style=\"text-align: center; "
+ htsbuf_qprintf(tq, "<hr>\r\n");
+ htsbuf_qprintf(tq, "<div style=\"text-align: center; "
"overflow: auto; width: 100%\">");
ajax_button(tq, "Select all", "select_all()");
ajax_button(tq, "Select none", "select_none()");
ajax_button(tq, "Invert selection", "select_invert()");
ajax_button(tq, "Select channels with sources", "select_sources()");
- tcp_qprintf(tq, "</div>\r\n");
+ htsbuf_qprintf(tq, "</div>\r\n");
- tcp_qprintf(tq, "<hr>\r\n");
+ htsbuf_qprintf(tq, "<hr>\r\n");
- tcp_qprintf(tq, "<div style=\"text-align: center; "
+ htsbuf_qprintf(tq, "<div style=\"text-align: center; "
"overflow: auto; width: 100%\">");
ajax_button(tq,
"Delete all selected...",
"select_do('delete', '%d', 0, true);", tcg->tcg_tag);
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<select id=\"movetarget\" "
"onChange=\"select_do('changegroup', "
"$('movetarget').value, '%d', false)\">", tcg->tcg_tag);
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<option value="">Move selected channels to group:</option>");
TAILQ_FOREACH(tcg2, &all_channel_groups, tcg_global_link) {
if(tcg2->tcg_hidden || tcg == tcg2)
continue;
- tcp_qprintf(tq, "<option value=\"%d\">%s</option>",
+ htsbuf_qprintf(tq, "<option value=\"%d\">%s</option>",
tcg2->tcg_tag, tcg2->tcg_name);
}
- tcp_qprintf(tq, "</select></div>");
- tcp_qprintf(tq, "</div>");
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</select></div>");
+ htsbuf_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</div>");
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
ajax_cheditor(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
channel_t *ch, *ch2;
channel_group_t *chg;
th_transport_t *t;
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, ch->ch_name);
if(ch->ch_icon != NULL) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div style=\"width: 100%; text-align:center\">"
"<img src=\"%s\"></div>", ch->ch_icon);
}
- tcp_qprintf(tq, "<div>Sources:</div>");
+ htsbuf_qprintf(tq, "<div>Sources:</div>");
LIST_FOREACH(t, &ch->ch_transports, tht_ch_link) {
ajax_box_begin(tq, AJAX_BOX_BORDER, NULL, NULL, NULL);
- tcp_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
- tcp_qprintf(tq, "<div style=\"float: left; width: 13%%\">%s</div>",
+ htsbuf_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
+ htsbuf_qprintf(tq, "<div style=\"float: left; width: 13%%\">%s</div>",
val2str(t->tht_type, sourcetypetab) ?: "???");
- tcp_qprintf(tq, "<div style=\"float: left; width: 87%%\">\"%s\"%s</div>",
+ htsbuf_qprintf(tq, "<div style=\"float: left; width: 87%%\">\"%s\"%s</div>",
t->tht_svcname, t->tht_scrambled ? " - (scrambled)" : "");
s = t->tht_sourcename ? t->tht_sourcename(t) : NULL;
- tcp_qprintf(tq, "</div><div style=\"overflow: auto; width: 100%\">");
+ htsbuf_qprintf(tq, "</div><div style=\"overflow: auto; width: 100%\">");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div style=\"float: left; width: 13%%\">"
"<input %stype=\"checkbox\" class=\"nicebox\" "
"onClick=\"new Ajax.Request('/ajax/transport_chdisable/%s', "
t->tht_identifier);
if(s != NULL)
- tcp_qprintf(tq, "<div style=\"float: left; width: 87%%\">%s</div>",
+ htsbuf_qprintf(tq, "<div style=\"float: left; width: 87%%\">%s</div>",
s);
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</div>");
ajax_box_end(tq, AJAX_BOX_BORDER);
}
- tcp_qprintf(tq, "<hr>\r\n");
+ htsbuf_qprintf(tq, "<hr>\r\n");
- tcp_qprintf(tq, "<div style=\"overflow: auto; width:100%%\">");
+ htsbuf_qprintf(tq, "<div style=\"overflow: auto; width:100%%\">");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<input type=\"button\" value=\"Rename...\" "
"onClick=\"channel_rename('%d', '%s')\">",
ch->ch_tag, ch->ch_name);
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<input type=\"button\" value=\"Delete...\" "
"onClick=\"channel_delete('%d', '%s')\">",
ch->ch_tag, ch->ch_name);
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<select "
"onChange=\"channel_merge('%d', this.value);\">",
ch->ch_tag);
- tcp_qprintf(tq, "<option value=\"n\">Merge to channel:</option>");
+ htsbuf_qprintf(tq, "<option value=\"n\">Merge to channel:</option>");
TAILQ_FOREACH(chg, &all_channel_groups, tcg_global_link) {
TAILQ_FOREACH(ch2, &chg->tcg_channels, ch_group_link) {
if(ch2 != ch)
- tcp_qprintf(tq, "<option value=\"%d\">%s</option>",
+ htsbuf_qprintf(tq, "<option value=\"%d\">%s</option>",
ch2->ch_tag, ch2->ch_name);
}
}
- tcp_qprintf(tq, "</select>");
- tcp_qprintf(tq, "</div>");
- tcp_qprintf(tq, "<hr>\r\n");
+ htsbuf_qprintf(tq, "</select>");
+ htsbuf_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "<hr>\r\n");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div class=\"infoprefixwidewidefat\">"
"Commercial detection:</div>"
"<div>"
ch->ch_tag);
for(i = 0; i < sizeof(cdlongname) / sizeof(cdlongname[0]); i++) {
- tcp_qprintf(tq, "<option %svalue=%d>%s</option>",
+ htsbuf_qprintf(tq, "<option %svalue=%d>%s</option>",
cdlongname[i].val == ch->ch_commercial_detection ?
"selected " : "",
cdlongname[i].val, cdlongname[i].str);
}
- tcp_qprintf(tq, "</select></div>");
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</select></div>");
+ htsbuf_qprintf(tq, "</div>");
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
ajax_changegroup(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
channel_t *ch;
channel_group_t *tcg;
http_arg_t *ra;
channel_set_group(ch, tcg);
}
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"$('cheditortab').innerHTML=''; "
"new Ajax.Updater('groupeditortab', "
"'/ajax/chgroup_editor/%s', "
ajax_chrename(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
channel_t *ch;
const char *s;
return HTTP_STATUS_BAD_REQUEST;
if(channel_rename(ch, s)) {
- tcp_qprintf(tq, "alert('Channel already exist');");
+ htsbuf_qprintf(tq, "alert('Channel already exist');");
} else {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"new Ajax.Updater('groupeditortab', "
"'/ajax/chgroup_editor/%d', "
"{method: 'get', evalScripts: true});\r\n",
ch->ch_group->tcg_tag);
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"new Ajax.Updater('cheditortab', "
"'/ajax/cheditor/%d', "
"{method: 'get', evalScripts: true});\r\n",
ajax_chdelete(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
channel_t *ch;
channel_group_t *tcg;
channel_delete(ch);
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"new Ajax.Updater('groupeditortab', "
"'/ajax/chgroup_editor/%d', "
"{method: 'get', evalScripts: true});\r\n",
tcg->tcg_tag);
- tcp_qprintf(tq, "$('cheditortab').innerHTML='';\r\n");
+ htsbuf_qprintf(tq, "$('cheditortab').innerHTML='';\r\n");
http_output(hc, hr, "text/javascript; charset=UTF-8", NULL, 0);
return 0;
ajax_chmerge(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
channel_t *src, *dst;
channel_group_t *tcg;
const char *s;
tcg = src->ch_group;
channel_merge(dst, src);
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"new Ajax.Updater('groupeditortab', "
"'/ajax/chgroup_editor/%d', "
"{method: 'get', evalScripts: true});\r\n",
tcg->tcg_tag);
- tcp_qprintf(tq, "$('cheditortab').innerHTML='';\r\n");
+ htsbuf_qprintf(tq, "$('cheditortab').innerHTML='';\r\n");
http_output(hc, hr, "text/javascript; charset=UTF-8", NULL, 0);
return 0;
ajax_chdeletemulti(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
channel_t *ch;
http_arg_t *ra;
const char *curgrp;
channel_delete(ch);
}
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"$('cheditortab').innerHTML=''; "
"new Ajax.Updater('groupeditortab', "
"'/ajax/chgroup_editor/%s', "
int
ajax_config_cwc_tab(http_connection_t *hc, http_reply_t *hr)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *q = &hr->hr_q;
- ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, "Code-word Client");
+ ajax_box_begin(q, AJAX_BOX_SIDEBOX, NULL, NULL, "Code-word Client");
- tcp_qprintf(tq, "<div id=\"cwclist\"></div>");
+ htsbuf_qprintf(q, "<div id=\"cwclist\"></div>");
- ajax_js(tq,
+ ajax_js(q,
"new Ajax.Updater('cwclist', '/ajax/cwclist', "
"{method: 'get', evalScripts: true});");
- tcp_qprintf(tq, "<hr><div style=\"overflow: auto; width: 100%\">");
+ htsbuf_qprintf(q, "<hr><div style=\"overflow: auto; width: 100%\">");
- tcp_qprintf(tq,
+ htsbuf_qprintf(q,
"<div class=\"cell_100\">"
"<div class=\"infoprefixwidewidefat\">Hostname:</div>"
"<div>"
"<input type=\"text\" size=40 id=\"hostname\">"
"</div></div>");
- tcp_qprintf(tq,
+ htsbuf_qprintf(q,
"<div class=\"cell_100\">"
"<div class=\"infoprefixwidewidefat\">Port:</div>"
"<div>"
"</div></div>");
- tcp_qprintf(tq,
+ htsbuf_qprintf(q,
"<div class=\"cell_100\">"
"<div class=\"infoprefixwidewidefat\">Username:</div>"
"<div>"
"<input type=\"text\" id=\"username\">"
"</div></div>");
- tcp_qprintf(tq,
+ htsbuf_qprintf(q,
"<div class=\"cell_100\">"
"<div class=\"infoprefixwidewidefat\">Password:</div>"
"<div>"
"<input type=\"password\" id=\"password\">"
"</div></div>");
- tcp_qprintf(tq,
+ htsbuf_qprintf(q,
"<div class=\"cell_100\">"
"<div class=\"infoprefixwidewidefat\">DES-key:</div>"
"<div>"
"<input type=\"text\" size=50 id=\"deskey\">"
"</div></div>");
- tcp_qprintf(tq,
+ htsbuf_qprintf(q,
"<br>"
"<input type=\"button\" value=\"Add new server entry\" "
"onClick=\"new Ajax.Request('/ajax/cwcadd', "
"}})"
"\">");
- tcp_qprintf(tq, "</div>\r\n");
+ htsbuf_qprintf(q, "</div>\r\n");
- ajax_box_end(tq, AJAX_BOX_SIDEBOX);
+ ajax_box_end(q, AJAX_BOX_SIDEBOX);
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(q, "</div>");
http_output_html(hc, hr);
return 0;
}
ajax_cwclist(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *q = &hr->hr_q;
ajax_table_t ta;
cwc_t *cwc;
char id[20];
- ajax_table_top(&ta, hc, tq,
+ ajax_table_top(&ta, hc, q,
(const char *[]){"Code-word Server",
"Username",
"Enabled",
ajax_cwcadd(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *q = &hr->hr_q;
const char *errtxt;
errtxt = cwc_add(http_arg_get(&hc->hc_req_args, "hostname"),
"1", 1, 1);
if(errtxt != NULL) {
- tcp_qprintf(tq, "alert('%s');", errtxt);
+ htsbuf_qprintf(q, "alert('%s');", errtxt);
} else {
- tcp_qprintf(tq, "$('hostname').clear();\r\n");
- tcp_qprintf(tq, "$('port').clear();\r\n");
- tcp_qprintf(tq, "$('username').clear();\r\n");
- tcp_qprintf(tq, "$('password').clear();\r\n");
- tcp_qprintf(tq, "$('deskey').clear();\r\n");
- tcp_qprintf(tq,
+ htsbuf_qprintf(q, "$('hostname').clear();\r\n");
+ htsbuf_qprintf(q, "$('port').clear();\r\n");
+ htsbuf_qprintf(q, "$('username').clear();\r\n");
+ htsbuf_qprintf(q, "$('password').clear();\r\n");
+ htsbuf_qprintf(q, "$('deskey').clear();\r\n");
+ htsbuf_qprintf(q,
"new Ajax.Updater('cwclist', '/ajax/cwclist', "
"{method: 'get', evalScripts: true});");
}
ajax_cwcdel(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *q = &hr->hr_q;
const char *txt;
cwc_t *cwc;
return HTTP_STATUS_BAD_REQUEST;
cwc_delete(cwc);
- tcp_qprintf(tq,
+ htsbuf_qprintf(q,
"new Ajax.Updater('cwclist', '/ajax/cwclist', "
"{method: 'get', evalScripts: true});");
ajax_cwcchange(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- // tcp_queue_t *tq = &hr->hr_tq;
+ // htsbuf_queue_t *q = &hr->hr_q;
const char *txt;
cwc_t *cwc;
static void
-add_option(tcp_queue_t *tq, int bol, const char *name)
+add_option(htsbuf_queue_t *tq, int bol, const char *name)
{
if(bol)
- tcp_qprintf(tq, "<option>%s</option>", name);
+ htsbuf_qprintf(tq, "<option>%s</option>", name);
}
/**
ajax_adaptersummary(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
th_dvb_adapter_t *tda;
char dispname[20];
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, dispname);
- tcp_qprintf(tq, "<div class=\"infoprefix\">Device:</div>"
+ htsbuf_qprintf(tq, "<div class=\"infoprefix\">Device:</div>"
"<div>%s</div>",
tda->tda_rootpath ?: "<b><i>Not present</i></b>");
- tcp_qprintf(tq, "<div class=\"infoprefix\">Type:</div>"
+ htsbuf_qprintf(tq, "<div class=\"infoprefix\">Type:</div>"
"<div>%s</div>",
dvb_adaptertype_to_str(tda->tda_type));
- tcp_qprintf(tq, "<div style=\"text-align: center\">"
+ htsbuf_qprintf(tq, "<div style=\"text-align: center\">"
"<a href=\"javascript:void(0);\" "
"onClick=\"new Ajax.Updater('dvbadaptereditor', "
"'/ajax/dvbadaptereditor/%s', "
int
ajax_config_dvb_tab(http_connection_t *hc, http_reply_t *hr)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
th_dvb_adapter_t *tda;
- tcp_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
+ htsbuf_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
if(TAILQ_FIRST(&dvb_adapters) == NULL) {
- tcp_qprintf(tq, "<div style=\"text-align: center; font-weight: bold\">"
+ htsbuf_qprintf(tq, "<div style=\"text-align: center; font-weight: bold\">"
"No adapters found</div>");
}
TAILQ_FOREACH(tda, &dvb_adapters, tda_global_link) {
- tcp_qprintf(tq, "<div id=\"summary_%s\" "
+ htsbuf_qprintf(tq, "<div id=\"summary_%s\" "
"style=\"float:left; width: 250px\"></div>",
tda->tda_identifier);
tda->tda_identifier, tda->tda_identifier);
}
- tcp_qprintf(tq, "</div>");
- tcp_qprintf(tq, "<div id=\"dvbadaptereditor\"></div>");
+ htsbuf_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "<div id=\"dvbadaptereditor\"></div>");
http_output_html(hc, hr);
return 0;
}
ajax_adaptereditor(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
th_dvb_adapter_t *tda, *tda2;
const char *s;
ajax_box_begin(tq, AJAX_BOX_FILLED, NULL, NULL, NULL);
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div id=\"adaptername_%s\" "
"style=\"text-align: center; font-weight: bold\">%s</div>",
tda->tda_identifier, tda->tda_displayname);
/* Type */
- tcp_qprintf(tq, "<div style=\"overflow: auto; width:100%%\">");
+ htsbuf_qprintf(tq, "<div style=\"overflow: auto; width:100%%\">");
- tcp_qprintf(tq, "<div style=\"float: left; width:45%%\">");
+ htsbuf_qprintf(tq, "<div style=\"float: left; width:45%%\">");
- tcp_qprintf(tq, "<div class=\"infoprefixwide\">Model:</div>"
+ htsbuf_qprintf(tq, "<div class=\"infoprefixwide\">Model:</div>"
"<div>%s (%s)</div>",
tda->tda_fe_info ? tda->tda_fe_info->name : "<Unknown>",
dvb_adaptertype_to_str(tda->tda_type));
if(tda->tda_fe_info != NULL) {
s = tda->tda_type == FE_QPSK ? "kHz" : "Hz";
- tcp_qprintf(tq, "<div class=\"infoprefixwide\">Freq. Range:</div>"
+ htsbuf_qprintf(tq, "<div class=\"infoprefixwide\">Freq. Range:</div>"
"<div>%s - %s %s, in steps of %s %s</div>",
nicenum(tda->tda_fe_info->frequency_min),
nicenum(tda->tda_fe_info->frequency_max),
if(tda->tda_fe_info->symbol_rate_min) {
- tcp_qprintf(tq, "<div class=\"infoprefixwide\">Symbolrate:</div>"
+ htsbuf_qprintf(tq, "<div class=\"infoprefixwide\">Symbolrate:</div>"
"<div>%s - %s Baud</div>",
nicenum(tda->tda_fe_info->symbol_rate_min),
nicenum(tda->tda_fe_info->symbol_rate_max));
}
/* Capabilities */
- // tcp_qprintf(tq, "<div class=\"infoprefixwide\">Capabilities:</div>");
+ // htsbuf_qprintf(tq, "<div class=\"infoprefixwide\">Capabilities:</div>");
}
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</div>");
- tcp_qprintf(tq, "<div style=\"float: left; width:55%%\">");
+ htsbuf_qprintf(tq, "<div style=\"float: left; width:55%%\">");
- tcp_qprintf(tq, "<div style=\"overflow: auto; width:100%%\">");
+ htsbuf_qprintf(tq, "<div style=\"overflow: auto; width:100%%\">");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<input type=\"button\" value=\"Rename adapter...\" "
"onClick=\"dvb_adapter_rename('%s', '%s');\">",
tda->tda_identifier, tda->tda_displayname);
if(tda->tda_rootpath == NULL) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<input type=\"button\" value=\"Delete adapter...\" "
"onClick=\"dvb_adapter_delete('%s', '%s');\">",
tda->tda_identifier, tda->tda_displayname);
}
- // tcp_qprintf(tq, "</div>");
+ // htsbuf_qprintf(tq, "</div>");
/* Clone adapter */
- // tcp_qprintf(tq, "<div style=\"overflow: auto; width:100%%\">");
- tcp_qprintf(tq,
+ // htsbuf_qprintf(tq, "<div style=\"overflow: auto; width:100%%\">");
+ htsbuf_qprintf(tq,
"<select "
"onChange=\"new Ajax.Request('/ajax/dvbadapterclone/%s', "
"{parameters: { source: this.value }})\">",
tda->tda_identifier);
- tcp_qprintf(tq, "<option value=\"n\">Clone settings from adapter:</option>");
+ htsbuf_qprintf(tq, "<option value=\"n\">Clone settings from adapter:</option>");
TAILQ_FOREACH(tda2, &dvb_adapters, tda_global_link) {
if(tda2 == tda || tda2->tda_type != tda->tda_type)
continue;
- tcp_qprintf(tq, "<option value=\"%s\">%s (%s)</option>",
+ htsbuf_qprintf(tq, "<option value=\"%s\">%s (%s)</option>",
tda2->tda_identifier, tda2->tda_displayname,
tda2->tda_rootpath ?: "not present");
}
- tcp_qprintf(tq, "</select></div>");
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</select></div>");
+ htsbuf_qprintf(tq, "</div>");
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</div>");
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</div>");
/* Muxes and transports */
- tcp_qprintf(tq, "<div style=\"float: left; width:45%\">");
+ htsbuf_qprintf(tq, "<div style=\"float: left; width:45%\">");
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, "Multiplexes");
- tcp_qprintf(tq, "<div id=\"dvbmuxlist_%s\"></div>",
+ htsbuf_qprintf(tq, "<div id=\"dvbmuxlist_%s\"></div>",
tda->tda_identifier);
ajax_js(tq,
tda->tda_identifier, tda->tda_identifier);
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</div>");
/* Div for displaying services */
- tcp_qprintf(tq, "<div id=\"servicepane\" style=\"float: left; width:55%\">");
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "<div id=\"servicepane\" style=\"float: left; width:55%\">");
+ htsbuf_qprintf(tq, "</div>");
http_output_html(hc, hr);
return 0;
ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
th_dvb_adapter_t *tda;
int caps;
int fetype;
/* Manual configuration */
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div style=\"text-align: center; font-weight: bold\">"
"Manual configuartion</div>");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div class=\"cell_50\">"
"<div class=\"infoprefixwidewidefat\">Frequency (%s):</div>"
"<div>"
if(fetype == FE_QAM || fetype == FE_QPSK) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div class=\"cell_50\">"
"<div class=\"infoprefixwidewidefat\">Symbolrate:</div>"
"<div>"
/* Bandwidth */
if(fetype == FE_OFDM) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div class=\"cell_50\">"
"<div class=\"infoprefixwidewidefat\">Bandwidth:</div>"
"<div><select id=\"bw\">");
add_option(tq, 1 , "8MHz");
add_option(tq, 1 , "7MHz");
add_option(tq, 1 , "6MHz");
- tcp_qprintf(tq, "</select></div></div>");
+ htsbuf_qprintf(tq, "</select></div></div>");
snprintf(params + strlen(params), sizeof(params) - strlen(params),
", bw: $F('bw')");
if(fetype == FE_QAM || fetype == FE_OFDM) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div class=\"cell_50\">"
"<div class=\"infoprefixwidewidefat\">Constellation:</div>"
"<div><select id=\"const\">");
add_option(tq, caps & FE_CAN_QAM_128, "QAM128");
add_option(tq, caps & FE_CAN_QAM_256, "QAM256");
- tcp_qprintf(tq, "</select></div></div>");
+ htsbuf_qprintf(tq, "</select></div></div>");
snprintf(params + strlen(params), sizeof(params) - strlen(params),
", const: $F('const')");
/* FEC */
if(fetype == FE_QAM || fetype == FE_QPSK) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div class=\"cell_50\">"
"<div class=\"infoprefixwidewidefat\">FEC:</div>"
"<div><select id=\"fec\">");
add_option(tq, caps & FE_CAN_FEC_6_7, "6/7");
add_option(tq, caps & FE_CAN_FEC_7_8, "7/8");
add_option(tq, caps & FE_CAN_FEC_8_9, "8/9");
- tcp_qprintf(tq, "</select></div></div>");
+ htsbuf_qprintf(tq, "</select></div></div>");
snprintf(params + strlen(params), sizeof(params) - strlen(params),
", fec: $F('fec')");
}
if(fetype == FE_QPSK) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div class=\"cell_50\">"
"<div class=\"infoprefixwidewidefat\">Polarisation:</div>"
"<div><select id=\"pol\">");
add_option(tq, 1, "Vertical");
add_option(tq, 1, "Horizontal");
- tcp_qprintf(tq, "</select></div></div>");
+ htsbuf_qprintf(tq, "</select></div></div>");
snprintf(params + strlen(params), sizeof(params) - strlen(params),
", pol: $F('pol')");
if(fetype == FE_OFDM) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div class=\"cell_50\">"
"<div class=\"infoprefixwidewidefat\">Transmission mode:</div>"
"<div><select id=\"tmode\">");
add_option(tq, caps & FE_CAN_TRANSMISSION_MODE_AUTO, "AUTO");
add_option(tq, 1 , "2k");
add_option(tq, 1 , "8k");
- tcp_qprintf(tq, "</select></div></div>");
+ htsbuf_qprintf(tq, "</select></div></div>");
snprintf(params + strlen(params), sizeof(params) - strlen(params),
", tmode: $F('tmode')");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div class=\"cell_50\">"
"<div class=\"infoprefixwidewidefat\">Guard interval:</div>"
"<div><select id=\"guard\">");
add_option(tq, 1 , "1/16");
add_option(tq, 1 , "1/8");
add_option(tq, 1 , "1/4");
- tcp_qprintf(tq, "</select></div></div>");
+ htsbuf_qprintf(tq, "</select></div></div>");
snprintf(params + strlen(params), sizeof(params) - strlen(params),
", guard: $F('guard')");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div class=\"cell_50\">"
"<div class=\"infoprefixwidewidefat\">Hierarchy:</div>"
"<div><select id=\"hier\">");
add_option(tq, 1 , "2");
add_option(tq, 1 , "4");
add_option(tq, 1 , "NONE");
- tcp_qprintf(tq, "</select></div></div>");
+ htsbuf_qprintf(tq, "</select></div></div>");
snprintf(params + strlen(params), sizeof(params) - strlen(params),
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div class=\"cell_50\">"
"<div class=\"infoprefixwidewidefat\">FEC Hi:</div>"
"<div><select id=\"fechi\">");
add_option(tq, caps & FE_CAN_FEC_6_7, "6/7");
add_option(tq, caps & FE_CAN_FEC_7_8, "7/8");
add_option(tq, caps & FE_CAN_FEC_8_9, "8/9");
- tcp_qprintf(tq, "</select></div></div>");
+ htsbuf_qprintf(tq, "</select></div></div>");
snprintf(params + strlen(params), sizeof(params) - strlen(params),
", fechi: $F('fechi')");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div class=\"cell_50\">"
"<div class=\"infoprefixwidewidefat\">FEC Low:</div>"
"<div><select id=\"feclo\">");
add_option(tq, caps & FE_CAN_FEC_6_7, "6/7");
add_option(tq, caps & FE_CAN_FEC_7_8, "7/8");
add_option(tq, caps & FE_CAN_FEC_8_9, "8/9");
- tcp_qprintf(tq, "</select></div></div>");
+ htsbuf_qprintf(tq, "</select></div></div>");
snprintf(params + strlen(params), sizeof(params) - strlen(params),
", feclo: $F('feclo')");
}
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<br>"
"<div style=\"text-align: center\">"
"<input type=\"button\" value=\"Add manually configured mux\" "
* Preconfigured
*/
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<hr>"
"<div style=\"text-align: center; font-weight: bold\">"
"Preconfigured network</div>");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div style=\"text-align: center\">"
"<select id=\"network\" "
"onChange=\"new Ajax.Updater('networkinfo', "
"'/ajax/dvbnetworkinfo/' + this.value)\""
">");
- tcp_qprintf(tq, "<option>Select a network</option>");
+ htsbuf_qprintf(tq, "<option>Select a network</option>");
n = 0;
while((type = dvb_mux_preconf_get(n, &networkname, NULL)) >= 0) {
if(type == fetype)
- tcp_qprintf(tq, "<option value=%d>%s</option>", n, networkname);
+ htsbuf_qprintf(tq, "<option value=%d>%s</option>", n, networkname);
n++;
}
- tcp_qprintf(tq, "</select></div>");
+ htsbuf_qprintf(tq, "</select></div>");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div class=\"cell_100_center\" id=\"networkinfo\"></div>");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<br>"
"<div style=\"text-align: center\">"
"<input type=\"button\" value=\"Add preconfigured network\" "
ajax_adaptercreatemux(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq;
+ htsbuf_queue_t *tq;
th_dvb_adapter_t *tda;
const char *v;
http_arg_get(&hc->hc_req_args, "port"), 1);
- tq = &hr->hr_tq;
+ tq = &hr->hr_q;
if(v != NULL)
- tcp_qprintf(tq, "alert('%s');\r\n", v);
+ htsbuf_qprintf(tq, "alert('%s');\r\n", v);
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"$('servicepane').innerHTML='';\r\n");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"new Ajax.Updater('dvbmuxlist_%s', "
"'/ajax/dvbadaptermuxlist/%s', "
"{method: 'get', evalScripts: true});\r\n",
{
ajax_table_t ta;
th_dvb_mux_instance_t *tdmi;
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
th_dvb_adapter_t *tda;
char buf[200];
int fetype, n, m;
nmuxes = tda->tda_muxes.entries;
if(nmuxes == 0) {
- tcp_qprintf(tq, "<div style=\"text-align: center\">"
+ htsbuf_qprintf(tq, "<div style=\"text-align: center\">"
"No muxes configured</div>");
} else {
ajax_table_bottom(&ta);
- tcp_qprintf(tq, "<hr><div style=\"overflow: auto; width: 100%\">");
+ htsbuf_qprintf(tq, "<hr><div style=\"overflow: auto; width: 100%\">");
ajax_button(tq, "Select all", "mux_sel_all()");
ajax_button(tq, "Select none", "mux_sel_none()");
ajax_button(tq, "Delete selected...",
"mux_sel_do('dvbadapterdelmux/%s', '', '', true)",
tda->tda_identifier);
- tcp_qprintf(tq, "</div>\r\n");
+ htsbuf_qprintf(tq, "</div>\r\n");
}
if(tda->tda_fe_info != NULL) {
- tcp_qprintf(tq, "<hr><div style=\"overflow: auto; width: 100%\">");
+ htsbuf_qprintf(tq, "<hr><div style=\"overflow: auto; width: 100%\">");
ajax_button(tq, "Add new mux...",
"new Ajax.Updater('servicepane', "
"'/ajax/dvbadapteraddmux/%s', "
"{method: 'get', evalScripts: true})\"",
tda->tda_identifier);
- tcp_qprintf(tq, "</div>\r\n");
+ htsbuf_qprintf(tq, "</div>\r\n");
}
http_output_html(hc, hr);
return 0;
const char *remain, void *opaque)
{
th_dvb_mux_instance_t *tdmi;
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
char buf[1000];
th_transport_t *t;
struct th_transport_tree tree;
{
th_dvb_adapter_t *tda;
th_dvb_mux_instance_t *tdmi;
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
th_transport_t *t;
struct th_transport_tree tree;
int n = 0;
{
th_dvb_adapter_t *tda;
th_dvb_mux_instance_t *tdmi;
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
http_arg_t *ra;
if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
dvb_mux_destroy(tdmi);
}
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"new Ajax.Updater('dvbadaptereditor', "
"'/ajax/dvbadaptereditor/%s', "
"{method: 'get', evalScripts: true});",
{
th_dvb_adapter_t *tda;
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
const char *s;
if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
tda->tda_displayname = strdup(s);
dvb_tda_save(tda);
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"$('adaptername_%s').innerHTML='%s';",
tda->tda_identifier, tda->tda_displayname);
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"new Ajax.Updater('summary_%s', "
"'/ajax/dvbadaptersummary/%s', {method: 'get'})",
tda->tda_identifier, tda->tda_identifier);
ajax_dvbnetworkinfo(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
const char *s;
if(remain == NULL)
return HTTP_STATUS_NOT_FOUND;
if(dvb_mux_preconf_get(atoi(remain), NULL, &s) >= 0)
- tcp_qprintf(tq, "%s", s);
+ htsbuf_qprintf(tq, "%s", s);
http_output_html(hc, hr);
return 0;
ajax_dvbadapteraddnetwork(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
const char *s;
th_dvb_adapter_t *tda;
dvb_mux_preconf_add(tda, atoi(s));
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"$('servicepane').innerHTML='';\r\n");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"new Ajax.Updater('dvbmuxlist_%s', "
"'/ajax/dvbadaptermuxlist/%s', "
"{method: 'get', evalScripts: true});\r\n",
ajax_dvbadapterclone(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
th_dvb_adapter_t *src, *dst;
const char *s;
dvb_tda_clone(dst, src);
- tcp_qprintf(tq, "new Ajax.Updater('dvbadaptereditor', "
+ htsbuf_qprintf(tq, "new Ajax.Updater('dvbadaptereditor', "
"'/ajax/dvbadaptereditor/%s', "
"{method: 'get', evalScripts: true});\r\n",
dst->tda_identifier);
ajax_dvbadapterdelete(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
th_dvb_adapter_t *tda;
if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
return HTTP_STATUS_NOT_FOUND;
- tcp_qprintf(tq, "var o = $('summary_%s'); o.parentNode.removeChild(o);\r\n",
+ htsbuf_qprintf(tq, "var o = $('summary_%s'); o.parentNode.removeChild(o);\r\n",
tda->tda_identifier);
- tcp_qprintf(tq, "$('dvbadaptereditor').innerHTML ='';\r\n");
+ htsbuf_qprintf(tq, "$('dvbadaptereditor').innerHTML ='';\r\n");
dvb_tda_destroy(tda);
*
*/
int
-ajax_transport_build_list(http_connection_t *hc, tcp_queue_t *tq,
+ajax_transport_build_list(http_connection_t *hc, htsbuf_queue_t *tq,
struct th_transport_tree *tlist, int numtransports)
{
th_transport_t *t;
ajax_table_t ta;
- tcp_qprintf(tq, "<script type=\"text/javascript\">\r\n"
+ htsbuf_qprintf(tq, "<script type=\"text/javascript\">\r\n"
"//<![CDATA[\r\n");
/* Select all */
- tcp_qprintf(tq, "select_all = function() {\r\n");
+ htsbuf_qprintf(tq, "select_all = function() {\r\n");
RB_FOREACH(t, tlist, tht_tmp_link) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"$('sel_%s').checked = true;\r\n",
t->tht_identifier);
}
- tcp_qprintf(tq, "}\r\n");
+ htsbuf_qprintf(tq, "}\r\n");
/* Select none */
- tcp_qprintf(tq, "select_none = function() {\r\n");
+ htsbuf_qprintf(tq, "select_none = function() {\r\n");
RB_FOREACH(t, tlist, tht_tmp_link) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"$('sel_%s').checked = false;\r\n",
t->tht_identifier);
}
- tcp_qprintf(tq, "}\r\n");
+ htsbuf_qprintf(tq, "}\r\n");
/* Invert selection */
- tcp_qprintf(tq, "select_invert = function() {\r\n");
+ htsbuf_qprintf(tq, "select_invert = function() {\r\n");
RB_FOREACH(t, tlist, tht_tmp_link) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"$('sel_%s').checked = !$('sel_%s').checked;\r\n",
t->tht_identifier, t->tht_identifier);
}
- tcp_qprintf(tq, "}\r\n");
+ htsbuf_qprintf(tq, "}\r\n");
/* Select TV transports */
- tcp_qprintf(tq, "select_tv = function() {\r\n");
+ htsbuf_qprintf(tq, "select_tv = function() {\r\n");
RB_FOREACH(t, tlist, tht_tmp_link) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"$('sel_%s').checked = %s;\r\n",
t->tht_identifier,
transport_is_tv(t) ? "true" : "false");
}
- tcp_qprintf(tq, "}\r\n");
+ htsbuf_qprintf(tq, "}\r\n");
/* Select unscrambled TV transports */
- tcp_qprintf(tq, "select_tv_nocrypt = function() {\r\n");
+ htsbuf_qprintf(tq, "select_tv_nocrypt = function() {\r\n");
RB_FOREACH(t, tlist, tht_tmp_link) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"$('sel_%s').checked = %s;\r\n",
t->tht_identifier,
transport_is_tv(t) && !t->tht_scrambled ? "true" : "false");
}
- tcp_qprintf(tq, "}\r\n");
+ htsbuf_qprintf(tq, "}\r\n");
/* Perform the given op on all transprots */
- tcp_qprintf(tq, "selected_do = function(op) {\r\n"
+ htsbuf_qprintf(tq, "selected_do = function(op) {\r\n"
"var h = new Hash();\r\n"
);
RB_FOREACH(t, tlist, tht_tmp_link) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"if($('sel_%s').checked) {h.set('%s', 'selected') }\r\n",
t->tht_identifier, t->tht_identifier);
}
- tcp_qprintf(tq, " new Ajax.Request('/ajax/transport_op/' + op, "
+ htsbuf_qprintf(tq, " new Ajax.Request('/ajax/transport_op/' + op, "
"{parameters: h});\r\n");
- tcp_qprintf(tq, "}\r\n");
+ htsbuf_qprintf(tq, "}\r\n");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"\r\n//]]>\r\n"
"</script>\r\n");
/* Top */
- tcp_qprintf(tq, "<form id=\"transports\">");
+ htsbuf_qprintf(tq, "<form id=\"transports\">");
ajax_table_top(&ta, hc, tq,
(const char *[]){"Last status", "Crypto",
ajax_table_bottom(&ta);
- tcp_qprintf(tq, "<hr>\r\n");
+ htsbuf_qprintf(tq, "<hr>\r\n");
- tcp_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
+ htsbuf_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
ajax_button(tq, "Select all", "select_all()");
ajax_button(tq, "Select none", "select_none()");
- // tcp_qprintf(tq, "</div>\r\n");
- //tcp_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
+ // htsbuf_qprintf(tq, "</div>\r\n");
+ //htsbuf_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
ajax_button(tq, "Map selected", "selected_do('map');");
ajax_button(tq, "Unmap selected", "selected_do('unmap');");
ajax_button(tq, "Test and map selected", "selected_do('probe');");
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</div>");
- tcp_qprintf(tq, "</form>");
+ htsbuf_qprintf(tq, "</form>");
return 0;
}
{
th_transport_t *t;
const char *newname;
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
if(remain == NULL || (t = transport_find_by_identifier(remain)) == NULL)
return HTTP_STATUS_NOT_FOUND;
*
*/
static void
-ajax_map_unmap_channel(th_transport_t *t, tcp_queue_t *tq, int map)
+ajax_map_unmap_channel(th_transport_t *t, htsbuf_queue_t *tq, int map)
{
char buf[1000];
transport_unmap_channel(t);
ajax_transport_build_mapper_state(buf, sizeof(buf), t, map);
- tcp_qprintf(tq, "%s", buf);
+ htsbuf_qprintf(tq, "%s", buf);
}
const char *remain, void *opaque)
{
th_transport_t *t;
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
const char *op = remain;
http_arg_t *ra;
int
ajax_config_xmltv_tab(http_connection_t *hc, http_reply_t *hr)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
xmltv_grabber_t *xg;
int ngrabbers = 0;
ajax_table_t ta;
- tcp_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
+ htsbuf_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
switch(xmltv_globalstatus) {
default:
- tcp_qprintf(tq, "<p style=\"text-align: center; font-weight: bold\">"
+ htsbuf_qprintf(tq, "<p style=\"text-align: center; font-weight: bold\">"
"XMLTV subsystem is not yet fully initialized, please retry "
"in a few seconds</p></div>");
http_output_html(hc, hr);
return 0;
case XMLTVSTATUS_FIND_GRABBERS_NOT_FOUND:
- tcp_qprintf(tq, "<p style=\"text-align: center; font-weight: bold\">"
+ htsbuf_qprintf(tq, "<p style=\"text-align: center; font-weight: bold\">"
"XMLTV subsystem can not initialize</p>"
"<p style=\"text-align: center\">"
"Make sure that the 'tv_find_grabbers' executable is in "
break;
}
- tcp_qprintf(tq, "<div style=\"float: left; width:45%\">");
+ htsbuf_qprintf(tq, "<div style=\"float: left; width:45%\">");
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, "XMLTV grabbers");
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
- tcp_qprintf(tq, "</div>"
+ htsbuf_qprintf(tq, "</div>"
"<div id=\"grabberpane\" style=\"float: left; width:55%\">"
"</div>");
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</div>");
http_output_html(hc, hr);
return 0;
}
* Generate displaylisting
*/
static void
-xmltv_grabber_chlist(tcp_queue_t *tq, xmltv_grabber_t *xg)
+xmltv_grabber_chlist(htsbuf_queue_t *tq, xmltv_grabber_t *xg)
{
xmltv_channel_t *xc;
channel_group_t *tcg;
channel_t *ch;
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div style=\"overflow: auto; height: 450px\">");
TAILQ_FOREACH(xc, &xg->xg_channels, xc_link) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div style=\"overflow: auto; width: 100%%\">");
- tcp_qprintf(tq, "<div class=\"iconbackdrop\">");
+ htsbuf_qprintf(tq, "<div class=\"iconbackdrop\">");
if(xc->xc_icon_url != NULL) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<img style=\"border: 0px;\" src=\"%s\" height=62px\">",
xc->xc_icon_url);
} else {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div style=\"margin-top: 20px; text-align: center\">"
"No icon</div>");
}
- tcp_qprintf(tq, "</div>"); /* iconbackdrop */
+ htsbuf_qprintf(tq, "</div>"); /* iconbackdrop */
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div class=\"infoprefixwide\">Name:</div>"
"<div>%s (%s)</div>", xc->xc_displayname, xc->xc_name);
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div class=\"infoprefixwide\">Auto mapper:</div>"
"<div>%s</div>", xc->xc_bestmatch ?: "(no channel)");
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<div class=\"infoprefixwidefat\">Channel:</div>"
"<select class=\"textinput\" "
"onChange=\"new Ajax.Request('/ajax/xmltvgrabberchmap/%s', "
"{parameters: { xmltvch: '%s', channel: this.value }})\">",
xg->xg_identifier, xc->xc_name);
- tcp_qprintf(tq, "<option value=\"auto\">Automatic mapper</option>",
+ htsbuf_qprintf(tq, "<option value=\"auto\">Automatic mapper</option>",
!xc->xc_disabled && xc->xc_channel == NULL ? " selected" : "");
- tcp_qprintf(tq, "<option value=\"none\"%s>No channel</option>",
+ htsbuf_qprintf(tq, "<option value=\"none\"%s>No channel</option>",
xc->xc_disabled ? " selected" : "");
TAILQ_FOREACH(tcg, &all_channel_groups, tcg_global_link) {
if(LIST_FIRST(&ch->ch_transports) == NULL)
continue;
- tcp_qprintf(tq, "<option value=\"%d\"%s>%s</option>",
+ htsbuf_qprintf(tq, "<option value=\"%d\"%s>%s</option>",
ch->ch_tag,
!strcmp(ch->ch_name, xc->xc_channel ?: "")
? " selected " : "", ch->ch_name);
}
}
- tcp_qprintf(tq, "</select>");
- tcp_qprintf(tq, "</div><hr>\r\n");
+ htsbuf_qprintf(tq, "</select>");
+ htsbuf_qprintf(tq, "</div><hr>\r\n");
}
- tcp_qprintf(tq, "</div>");
+ htsbuf_qprintf(tq, "</div>");
}
const char *remain, void *opaque)
{
xmltv_grabber_t *xg;
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
if(remain == NULL || (xg = xmltv_grabber_find(remain)) == NULL)
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, xg->xg_title);
- tcp_qprintf(tq,"<div id=\"details_%s\">", xg->xg_identifier);
+ htsbuf_qprintf(tq,"<div id=\"details_%s\">", xg->xg_identifier);
if(xg->xg_enabled == 0) {
- tcp_qprintf(tq,
+ htsbuf_qprintf(tq,
"<p>This grabber is currently not enabled, click "
"<a href=\"javascript:void(0);\" "
"onClick=\"new Ajax.Request('/ajax/xmltvgrabbermode/%s', "
} else if(xg->xg_status == XMLTV_GRAB_OK) {
xmltv_grabber_chlist(tq, xg);
} else {
- tcp_qprintf(tq, "<p>%s</p>", xmltv_grabber_status_long(xg));
+ htsbuf_qprintf(tq, "<p>%s</p>", xmltv_grabber_status_long(xg));
}
- tcp_qprintf(tq,"</div>");
+ htsbuf_qprintf(tq,"</div>");
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
http_output_html(hc, hr);
const char *remain, void *opaque)
{
xmltv_grabber_t *xg;
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
if(remain == NULL || (xg = xmltv_grabber_find(remain)) == NULL)
return HTTP_STATUS_NOT_FOUND;
xmltv_grabber_enable(xg);
- tcp_qprintf(tq,"$('details_%s').innerHTML='Please wait...';",
+ htsbuf_qprintf(tq,"$('details_%s').innerHTML='Please wait...';",
xg->xg_identifier);
http_output(hc, hr, "text/javascript; charset=UTF8", NULL, 0);
const char *remain, void *opaque)
{
xmltv_grabber_t *xg;
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *tq = &hr->hr_q;
if(remain == NULL || (xg = xmltv_grabber_find(remain)) == NULL)
return HTTP_STATUS_NOT_FOUND;
const char *xmltvname;
const char *chname;
channel_t *ch;
- // tcp_queue_t *tq = &hr->hr_tq;
+ // htsbuf_queue_t *tq = &hr->hr_tq;
if(remain == NULL || (xg = xmltv_grabber_find(remain)) == NULL)
return HTTP_STATUS_NOT_FOUND;
*
*/
void
-ajax_mailbox_start(tcp_queue_t *tq)
+ajax_mailbox_start(htsbuf_queue_t *hq)
{
struct timeval tv;
uint8_t sum[16];
mbdebug("Generated mailbox %s\n", id);
ajax_mailbox_create(id);
- ajax_js(tq, "mailboxquery('%s')", id);
+ ajax_js(hq, "mailboxquery('%s')", id);
}
mbdebug("mailbox[%s]: sending reply\n", amb->amb_boxid);
while((al = TAILQ_FIRST(&amb->amb_letters)) != NULL) {
- tcp_qprintf(&hr->hr_tq, "try {\r\n");
- tcp_qprintf(&hr->hr_tq, "%s%s", al->al_payload_a, al->al_payload_b ?: "");
+ htsbuf_qprintf(&hr->hr_q, "try {\r\n");
+ htsbuf_qprintf(&hr->hr_q, "%s%s",
+ al->al_payload_a, al->al_payload_b ?: "");
mbdebug("\t%s%s", al->al_payload_a, al->al_payload_b ?: "");
- tcp_qprintf(&hr->hr_tq, "}\r\n"
+ htsbuf_qprintf(&hr->hr_q, "}\r\n"
"catch(err) {}\r\n");
al_destroy(amb, al);
}
- tcp_qprintf(&hr->hr_tq, "mailboxquery('%s');\r\n", amb->amb_boxid);
+ htsbuf_qprintf(&hr->hr_q, "mailboxquery('%s');\r\n", amb->amb_boxid);
http_output(hr->hr_connection, hr, "text/javascript", NULL, 0);
amb->amb_hr = NULL;
#ifndef AJAXUI_MAILBOX_H_
#define AJAXUI_MAILBOX_H_
-#include "tcp.h"
+#include <libhts/htsbuf.h>
void ajax_mailbox_tdmi_state_change(th_dvb_mux_instance_t *tdmi);
void ajax_mailbox_tda_change(th_dvb_adapter_t *tda);
-void ajax_mailbox_start(tcp_queue_t *tq);
+void ajax_mailbox_start(htsbuf_queue_t *hq);
struct xmltv_grabber;
buf[0] = (len - 2) >> 8;
buf[1] = len - 2;
- tcp_send_msg(ses, &ses->tcp_q_hi, buf, len);
+ tcp_send_msg(ses, 0, buf, len);
/* Expect a response within 4 seconds */
dtimer_arm(&cwc->cwc_idle_timer, cwc_timeout, cwc, 4);
htsp_send_msg(htsp_t *htsp, htsmsg_t *m, int media)
{
tcp_session_t *tcp = &htsp->htsp_tcp_session;
- tcp_queue_t *tq;
+ htsbuf_queue_t *hq;
void *data;
size_t datalen;
+ int hiprio = !media;
int max, r = -1;
- tq = media ? &tcp->tcp_q_low : &tcp->tcp_q_hi;
-
- max = tq->tq_maxdepth - tq->tq_depth; /* max size we are able to enqueue */
+ hq = &tcp->tcp_q[hiprio];
+
+ max = hq->hq_maxsize - hq->hq_size; /* max size we are able to enqueue */
if(htsmsg_binary_serialize(m, &data, &datalen, max) == 0)
- r = tcp_send_msg(tcp, tq, data, datalen);
+ r = tcp_send_msg(tcp, hiprio, data, datalen);
htsmsg_destroy(m);
return r;
TAILQ_REMOVE(&hc->hc_replies, hr, hr_link);
free(hr->hr_location);
- tcp_flush_queue(&hr->hr_tq);
+ htsbuf_queue_flush(&hr->hr_q);
free(hr);
}
{
struct tm tm0, *tm;
time_t t;
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *hq = &hr->hr_q;
int r;
if(hr->hr_version >= HTTP_VERSION_1_0) {
"Content-Type: %s\r\n"
"Content-Length: %d\r\n"
"\r\n",
- hr->hr_content, tq->tq_depth);
+ hr->hr_content, hq->hq_size);
}
- tcp_output_queue(&hc->hc_tcp_session, NULL, tq);
+
+ tcp_output_queue(&hc->hc_tcp_session, 0, hq);
r = !hr->hr_keep_alive;
+
http_destroy_reply(hc, hr);
return r;
}
http_error(http_connection_t *hc, http_reply_t *hr, int error)
{
const char *errtxt = http_rc2str(error);
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *hq = &hr->hr_q;
- tcp_flush_queue(tq);
+ htsbuf_queue_flush(hq);
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
"<HTML><HEAD>\r\n"
"<TITLE>%d %s</TITLE>\r\n"
void
http_redirect(http_connection_t *hc, http_reply_t *hr, const char *location)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *hq = &hr->hr_q;
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
"<HTML><HEAD>\r\n"
"<TITLE>Redirect</TITLE>\r\n"
/* Insert reply in order */
TAILQ_INSERT_TAIL(&hc->hc_replies, hr, hr_link);
- tcp_init_queue(&hr->hr_tq, -1);
+ htsbuf_queue_init(&hr->hr_q, INT32_MAX);
hr->hr_connection = hc;
hr->hr_version = hc->hc_version;
hr->hr_keep_alive = hc->hc_keep_alive;
int n, v;
char *argv[3], *c;
- //printf("HTTP INPUT: %s\n", buf);
+ // printf("HTTP INPUT: %s\n", buf);
switch(hc->hc_state) {
case HTTP_CON_WAIT_REQUEST:
{
http_resource_t *hres = opaque;
- tcp_qput(&hr->hr_tq, hres->data, hres->len);
+ htsbuf_append(&hr->hr_q, hres->data, hres->len);
http_output(hc, hr, hres->content, hres->encoding, 15);
return 0;
}
const char *hr_encoding;
const char *hr_content;
- tcp_queue_t hr_tq;
+ htsbuf_queue_t hr_q;
} http_reply_t;
static void tcp_client_reconnect_timeout(void *aux, int64_t now);
-
-/*
- * vprintf data on a TCP queue
- */
-void
-tcp_qvprintf(tcp_queue_t *tq, const char *fmt, va_list ap)
-{
- char buf[5000];
- void *out;
- tcp_data_t *td;
-
- td = malloc(sizeof(tcp_data_t));
- td->td_offset = 0;
-
- td->td_datalen = vsnprintf(buf, sizeof(buf), fmt, ap);
- out = malloc(td->td_datalen);
- memcpy(out, buf, td->td_datalen);
- td->td_data = out;
- TAILQ_INSERT_TAIL(&tq->tq_messages, td, td_link);
- tq->tq_depth += td->td_datalen;
-}
-
-
-/*
- * printf data on a TCP queue
- */
-void
-tcp_qprintf(tcp_queue_t *tq, const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- tcp_qvprintf(tq, fmt, ap);
- va_end(ap);
-}
-
-/*
- * Put data on a TCP queue
- */
-void
-tcp_qput(tcp_queue_t *tq, const uint8_t *buf, size_t len)
-{
- tcp_data_t *td;
- void *out;
-
- td = malloc(sizeof(tcp_data_t));
- td->td_offset = 0;
- td->td_datalen = len;
-
- out = malloc(td->td_datalen);
- memcpy(out, buf, td->td_datalen);
- td->td_data = out;
- TAILQ_INSERT_TAIL(&tq->tq_messages, td, td_link);
- tq->tq_depth += td->td_datalen;
-}
-
-/*
- * printfs data on a TCP connection
- */
-void
-tcp_printf(tcp_session_t *ses, const char *fmt, ...)
-{
- va_list ap;
- char buf[5000];
- void *out;
- int l;
-
- va_start(ap, fmt);
- l = vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
-
- out = malloc(l);
- memcpy(out, buf, l);
-
- tcp_send_msg(ses, &ses->tcp_q_hi, out, l);
-}
-
/**
* Read max 'n' bytes of data from line parser. Used to consume binary data
* for mixed line / binary protocols (HTTP)
}
-
-/**
- * Create an output queue
- */
-void
-tcp_init_queue(tcp_queue_t *tq, int maxdepth)
-{
- TAILQ_INIT(&tq->tq_messages);
- tq->tq_depth = 0;
- tq->tq_maxdepth = maxdepth;
-}
-
-/**
- * Flusing all pending data from a queue
- */
-void
-tcp_flush_queue(tcp_queue_t *tq)
-{
- tcp_data_t *td;
-
- while((td = TAILQ_FIRST(&tq->tq_messages)) != NULL) {
- TAILQ_REMOVE(&tq->tq_messages, td, td_link);
- free((void *)td->td_data);
- free(td);
- }
-}
-
-
/**
* Transmit data from any of the queues
* Select hi-pri queue first if possible, but always stick on the same
static void
tcp_transmit(tcp_session_t *ses)
{
- tcp_queue_t *q = ses->tcp_q_current;
- tcp_data_t *hd;
+ htsbuf_queue_t *hq = ses->tcp_q_current;
+ htsbuf_data_t *hd;
int r;
again:
- if(q == NULL) {
- if(ses->tcp_q_hi.tq_depth)
- q = &ses->tcp_q_hi;
- if(ses->tcp_q_low.tq_depth)
- q = &ses->tcp_q_low;
+ if(hq == NULL) {
+ if(ses->tcp_q[1].hq_size)
+ hq = &ses->tcp_q[1];
+ else if(ses->tcp_q[0].hq_size)
+ hq = &ses->tcp_q[0];
}
- while(q != NULL) {
- hd = TAILQ_FIRST(&q->tq_messages);
+ while(hq != NULL) {
+ hd = TAILQ_FIRST(&hq->hq_q);
- r = write(ses->tcp_fd, hd->td_data + hd->td_offset,
- hd->td_datalen - hd->td_offset);
+ r = write(ses->tcp_fd, hd->hd_data + hd->hd_data_off,
+ hd->hd_data_len - hd->hd_data_off);
if(r == -1 && (errno == EAGAIN || errno == EWOULDBLOCK))
r = 0;
tcp_disconnect(ses, errno);
return;
}
- q->tq_depth -= r;
- hd->td_offset += r;
-
- if(hd->td_offset == hd->td_datalen) {
- TAILQ_REMOVE(&q->tq_messages, hd, td_link);
- free((void *)hd->td_data);
- free(hd);
- q = NULL;
+ hq->hq_size -= r;
+ hd->hd_data_off += r;
+
+ if(hd->hd_data_off == hd->hd_data_len) {
+ htsbuf_data_free(hq, hd);
+ hq = NULL;
goto again;
}
}
- if(q == NULL) {
+ if(hq == NULL) {
if(ses->tcp_blocked) {
dispatch_clr(ses->tcp_dispatch_handle, DISPATCH_WRITE);
ses->tcp_blocked = 0;
ses->tcp_blocked = 1;
}
}
- ses->tcp_q_current = q;
+ ses->tcp_q_current = hq;
}
/**
* being sent.
*/
int
-tcp_send_msg(tcp_session_t *ses, tcp_queue_t *tq, const void *data,
- size_t len)
+tcp_send_msg(tcp_session_t *ses, int hiprio, void *data, size_t len)
{
- tcp_data_t *td;
-
- if(tq == NULL)
- tq = &ses->tcp_q_low;
+ htsbuf_queue_t *hq = &ses->tcp_q[!!hiprio];
+ htsbuf_data_t *hd;
- if(len > tq->tq_maxdepth - tq->tq_depth) {
- free((void *)data);
+ if(len > hq->hq_maxsize - hq->hq_size) {
+ free(data);
return -1;
}
- td = malloc(sizeof(tcp_data_t));
- td->td_offset = 0;
- td->td_datalen = len;
- td->td_data = data;
- TAILQ_INSERT_TAIL(&tq->tq_messages, td, td_link);
- tq->tq_depth += td->td_datalen;
+ hd = malloc(sizeof(htsbuf_data_t));
+ hd->hd_data_off = 0;
+ hd->hd_data_len = len;
+ hd->hd_data = data;
+ TAILQ_INSERT_TAIL(&hq->hq_q, hd, hd_link);
+ hq->hq_size += len;
if(!ses->tcp_blocked)
tcp_transmit(ses);
return 0;
}
-
/**
- * Move a tcp queue onto a session
*
- * Coalesce smaller chunks into bigger ones for more efficient I/O
*/
void
-tcp_output_queue(tcp_session_t *ses, tcp_queue_t *dst, tcp_queue_t *src)
+tcp_printf(tcp_session_t *ses, const char *fmt, ...)
{
- tcp_data_t *sd;
- tcp_data_t *dd;
- int l, s;
-
- if(dst == NULL)
- dst = &ses->tcp_q_low;
-
- while((sd = TAILQ_FIRST(&src->tq_messages)) != NULL) {
+ va_list ap;
+ va_start(ap, fmt);
- l = 4096;
- if(sd->td_datalen > l)
- l = sd->td_datalen;
-
- dd = malloc(sizeof(tcp_data_t));
- dd->td_offset = 0;
- dd->td_data = malloc(l);
+ htsbuf_vqprintf(&ses->tcp_q[0], fmt, ap);
+ va_end(ap);
- s = 0; /* accumulated size */
- while((sd = TAILQ_FIRST(&src->tq_messages)) != NULL) {
+ if(!ses->tcp_blocked)
+ tcp_transmit(ses);
+}
- if(sd->td_datalen + s > l)
- break;
+/**
+ * Move a tcp queue onto a session
+ *
+ * Coalesce smaller chunks into bigger ones for more efficient I/O
+ */
+void
+tcp_output_queue(tcp_session_t *ses, int hiprio, htsbuf_queue_t *src)
+{
+ htsbuf_data_t *hd;
+ htsbuf_queue_t *dst = &ses->tcp_q[!!hiprio];
- memcpy((char *)dd->td_data + s, sd->td_data, sd->td_datalen);
- s += sd->td_datalen;
- TAILQ_REMOVE(&src->tq_messages, sd, td_link);
- free((void *)sd->td_data);
- free(sd);
- }
+ while((hd = TAILQ_FIRST(&src->hq_q)) != NULL) {
+ TAILQ_REMOVE(&src->hq_q, hd, hd_link);
+ TAILQ_INSERT_TAIL(&dst->hq_q, hd, hd_link);
- dd->td_datalen = s;
- TAILQ_INSERT_TAIL(&dst->tq_messages, dd, td_link);
- dst->tq_depth += s;
+ dst->hq_size += hd->hd_data_len;
}
+ src->hq_size = 0;
- if(ses != NULL && !ses->tcp_blocked)
+ if(!ses->tcp_blocked)
tcp_transmit(ses);
-
- src->tq_depth = 0;
}
/**
void
tcp_disconnect(tcp_session_t *ses, int err)
{
- tcp_flush_queue(&ses->tcp_q_low);
- tcp_flush_queue(&ses->tcp_q_hi);
+ htsbuf_queue_flush(&ses->tcp_q[0]);
+ htsbuf_queue_flush(&ses->tcp_q[1]);
ses->tcp_callback(TCP_DISCONNECT, ses);
val = 1;
setsockopt(ses->tcp_fd, SOL_TCP, TCP_NODELAY, &val, sizeof(val));
- tcp_init_queue(&ses->tcp_q_hi, 20 * 1000 * 1000);
- tcp_init_queue(&ses->tcp_q_low, 20 * 1000 * 1000);
+ htsbuf_queue_init(&ses->tcp_q[0], 20 * 1000 * 1000);
+ htsbuf_queue_init(&ses->tcp_q[1], 20 * 1000 * 1000);
snprintf(ses->tcp_peer_txt, sizeof(ses->tcp_peer_txt), "%s:%d",
inet_ntoa(si->sin_addr), ntohs(si->sin_port));
#ifndef TCP_H_
#define TCP_H_
-TAILQ_HEAD(tcp_data_queue, tcp_data);
-
-typedef struct tcp_data {
- TAILQ_ENTRY(tcp_data) td_link;
- const void *td_data;
- unsigned int td_datalen;
- int td_offset;
-} tcp_data_t;
-
-typedef struct tcp_queue {
- struct tcp_data_queue tq_messages;
- int tq_depth;
- int tq_maxdepth;
-} tcp_queue_t;
+#include <libhts/htsbuf.h>
typedef enum {
TCP_CONNECT,
/* Output queueing */
int tcp_blocked;
- tcp_queue_t tcp_q_hi;
- tcp_queue_t tcp_q_low;
+ htsbuf_queue_t tcp_q[2];
- tcp_queue_t *tcp_q_current;
+ htsbuf_queue_t *tcp_q_current;
/* Input line parser */
} tcp_session_t;
-void tcp_init_queue(tcp_queue_t *tq, int maxdepth);
-
-void tcp_flush_queue(tcp_queue_t *tq);
-
void tcp_disconnect(tcp_session_t *ses, int err);
void tcp_create_server(int port, size_t session_size, const char *name,
#define tcp_logname(ses) ((ses)->tcp_peer_txt)
-int tcp_send_msg(tcp_session_t *ses, tcp_queue_t *tq, const void *data,
- size_t len);
-
void tcp_printf(tcp_session_t *ses, const char *fmt, ...);
-void tcp_qprintf(tcp_queue_t *tq, const char *fmt, ...);
-
-void tcp_qvprintf(tcp_queue_t *tq, const char *fmt, va_list ap);
-
-void tcp_qput(tcp_queue_t *tq, const uint8_t *buf, size_t len);
-
-void tcp_output_queue(tcp_session_t *ses, tcp_queue_t *dst, tcp_queue_t *src);
+void tcp_output_queue(tcp_session_t *ses, int hiprio, htsbuf_queue_t *src);
void *tcp_create_client(const char *hostname, int port, size_t session_size,
const char *name, tcp_callback_t *cb, int enabled);
void tcp_enable_disable(tcp_session_t *ses, int enabled);
+int tcp_send_msg(tcp_session_t *ses, int hiprio, void *data, size_t len);
+
#endif /* TCP_H_ */
page_simple(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *hq = &hr->hr_q;
const char *s = http_arg_get(&hc->hc_req_args, "s");
struct event_list events;
event_t *e, **ev;
pvr_rec_t *pvrr, **pv;
const char *rstatus;
- tcp_qprintf(tq, "<html>");
- tcp_qprintf(tq, "<body>");
+ htsbuf_qprintf(hq, "<html>");
+ htsbuf_qprintf(hq, "<body>");
- tcp_qprintf(tq, "<form>");
- tcp_qprintf(tq, "Event: <input type=\"text\" ");
+ htsbuf_qprintf(hq, "<form>");
+ htsbuf_qprintf(hq, "Event: <input type=\"text\" ");
if(s != NULL)
- tcp_qprintf(tq, "value=\"%s\" ", s);
+ htsbuf_qprintf(hq, "value=\"%s\" ", s);
- tcp_qprintf(tq, "name=\"s\">");
- tcp_qprintf(tq, "<input type=\"submit\" value=\"Search\">");
+ htsbuf_qprintf(hq, "name=\"s\">");
+ htsbuf_qprintf(hq, "<input type=\"submit\" value=\"Search\">");
- tcp_qprintf(tq, "</form><hr>");
+ htsbuf_qprintf(hq, "</form><hr>");
if(s != NULL) {
c = epg_search(&events, s, NULL, NULL, NULL);
if(c == -1) {
- tcp_qprintf(tq, "<b>Event title: Regular expression syntax error</b>");
+ htsbuf_qprintf(hq, "<b>Event title: Regular expression syntax error</b>");
} else if(c == 0) {
- tcp_qprintf(tq, "<b>No matching entries found</b>");
+ htsbuf_qprintf(hq, "<b>No matching entries found</b>");
} else {
- tcp_qprintf(tq, "<b>%d entries found", c);
+ htsbuf_qprintf(hq, "<b>%d entries found", c);
ev = alloca(c * sizeof(event_t *));
c = 0;
if(c > 25) {
c = 25;
- tcp_qprintf(tq, ", %d entries shown", c);
+ htsbuf_qprintf(hq, ", %d entries shown", c);
}
- tcp_qprintf(tq, "</b>");
+ htsbuf_qprintf(hq, "</b>");
memset(&day, -1, sizeof(struct tm));
for(k = 0; k < c; k++) {
if(a.tm_wday != day.tm_wday || a.tm_mday != day.tm_mday ||
a.tm_mon != day.tm_mon || a.tm_year != day.tm_year) {
memcpy(&day, &a, sizeof(struct tm));
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"<br><i>%s, %d/%d</i><br>",
days[day.tm_wday], day.tm_mday, day.tm_mon + 1);
}
rstatus = pvrr != NULL ? val2str(pvrr->pvrr_status,
recstatustxt) : NULL;
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"<a href=\"/eventinfo/%d\">"
"%02d:%02d-%02d:%02d %s%s%s</a><br>",
e->e_tag,
rstatus ? " " : "", rstatus ?: "");
}
}
- tcp_qprintf(tq, "<hr>");
+ htsbuf_qprintf(hq, "<hr>");
}
- tcp_qprintf(tq, "<b>Recorder log:</b><br>\n");
+ htsbuf_qprintf(hq, "<b>Recorder log:</b><br>\n");
c = 0;
LIST_FOREACH(pvrr, &pvrr_global_list, pvrr_global_link)
c++;
if(c == 0) {
- tcp_qprintf(tq, "No entries<br>");
+ htsbuf_qprintf(hq, "No entries<br>");
}
pv = alloca(c * sizeof(pvr_rec_t *));
if(a.tm_wday != day.tm_wday || a.tm_mday != day.tm_mday ||
a.tm_mon != day.tm_mon || a.tm_year != day.tm_year) {
memcpy(&day, &a, sizeof(struct tm));
- tcp_qprintf(tq, "<br><i>%s, %d/%d</i><br>",
+ htsbuf_qprintf(hq, "<br><i>%s, %d/%d</i><br>",
days[day.tm_wday], day.tm_mday, day.tm_mon + 1);
}
rstatus = val2str(pvrr->pvrr_status, recstatustxt);
- tcp_qprintf(tq, "<a href=\"/pvrinfo/%d\">", pvrr->pvrr_ref);
+ htsbuf_qprintf(hq, "<a href=\"/pvrinfo/%d\">", pvrr->pvrr_ref);
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"%02d:%02d-%02d:%02d %s",
a.tm_hour, a.tm_min, b.tm_hour, b.tm_min, pvrr->pvrr_title);
- tcp_qprintf(tq, "</a>");
+ htsbuf_qprintf(hq, "</a>");
- tcp_qprintf(tq, "<br>(%s)<br><br>", rstatus);
+ htsbuf_qprintf(hq, "<br>(%s)<br><br>", rstatus);
}
- tcp_qprintf(tq, "</body></html>");
+ htsbuf_qprintf(hq, "</body></html>");
http_output_html(hc, hr);
return 0;
}
page_einfo(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *hq = &hr->hr_q;
event_t *e;
struct tm a, b;
time_t stop;
pvr_abort(pvrr);
}
- tcp_qprintf(tq, "<html>");
- tcp_qprintf(tq, "<body>");
+ htsbuf_qprintf(hq, "<html>");
+ htsbuf_qprintf(hq, "<body>");
localtime_r(&e->e_start, &a);
stop = e->e_start + e->e_duration;
localtime_r(&stop, &b);
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"%s, %d/%d %02d:%02d - %02d:%02d<br>",
days[a.tm_wday], a.tm_mday, a.tm_mon + 1,
a.tm_hour, a.tm_min, b.tm_hour, b.tm_min);
- tcp_qprintf(tq, "<hr><b>\"%s\": \"%s\"</b><br><br>",
+ htsbuf_qprintf(hq, "<hr><b>\"%s\": \"%s\"</b><br><br>",
e->e_channel->ch_name, e->e_title);
pvrstatus = pvrr != NULL ? pvrr->pvrr_status : HTSTV_PVR_STATUS_NONE;
if((rstatus = val2str(pvrstatus, recstatustxt)) != NULL)
- tcp_qprintf(tq, "Recording status: %s<br>", rstatus);
+ htsbuf_qprintf(hq, "Recording status: %s<br>", rstatus);
- tcp_qprintf(tq, "<form method=\"post\" action=\"/eventinfo/%d\">", e->e_tag);
+ htsbuf_qprintf(hq, "<form method=\"post\" action=\"/eventinfo/%d\">", e->e_tag);
switch(pvrstatus) {
case HTSTV_PVR_STATUS_SCHEDULED:
- tcp_qprintf(tq, "<input type=\"submit\" "
+ htsbuf_qprintf(hq, "<input type=\"submit\" "
"name=\"clear\" value=\"Remove from schedule\">");
break;
case HTSTV_PVR_STATUS_RECORDING:
- tcp_qprintf(tq, "<input type=\"submit\" "
+ htsbuf_qprintf(hq, "<input type=\"submit\" "
"name=\"cancel\" value=\"Cancel recording\">");
break;
case HTSTV_PVR_STATUS_NONE:
- tcp_qprintf(tq, "<input type=\"submit\" "
+ htsbuf_qprintf(hq, "<input type=\"submit\" "
"name=\"rec\" value=\"Record\">");
break;
default:
- tcp_qprintf(tq, "<input type=\"submit\" "
+ htsbuf_qprintf(hq, "<input type=\"submit\" "
"name=\"clear\" value=\"Clear error status\">");
break;
}
- tcp_qprintf(tq, "</form>");
- tcp_qprintf(tq, "%s", e->e_desc);
+ htsbuf_qprintf(hq, "</form>");
+ htsbuf_qprintf(hq, "%s", e->e_desc);
- tcp_qprintf(tq, "<hr><a href=\"/simple.html\">New search</a><br>");
- tcp_qprintf(tq, "</body></html>");
+ htsbuf_qprintf(hq, "<hr><a href=\"/simple.html\">New search</a><br>");
+ htsbuf_qprintf(hq, "</body></html>");
http_output_html(hc, hr);
return 0;
}
page_pvrinfo(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
- tcp_queue_t *tq = &hr->hr_tq;
+ htsbuf_queue_t *hq = &hr->hr_q;
struct tm a, b;
time_t stop;
pvr_rec_t *pvrr = NULL;
pvr_abort(pvrr);
}
- tcp_qprintf(tq, "<html>");
- tcp_qprintf(tq, "<body>");
+ htsbuf_qprintf(hq, "<html>");
+ htsbuf_qprintf(hq, "<body>");
localtime_r(&pvrr->pvrr_start, &a);
stop = pvrr->pvrr_start + pvrr->pvrr_stop;
localtime_r(&stop, &b);
- tcp_qprintf(tq,
+ htsbuf_qprintf(hq,
"%s, %d/%d %02d:%02d - %02d:%02d<br>",
days[a.tm_wday], a.tm_mday, a.tm_mon + 1,
a.tm_hour, a.tm_min, b.tm_hour, b.tm_min);
- tcp_qprintf(tq, "<hr><b>\"%s\": \"%s\"</b><br><br>",
+ htsbuf_qprintf(hq, "<hr><b>\"%s\": \"%s\"</b><br><br>",
pvrr->pvrr_channel->ch_name, pvrr->pvrr_title);
pvrstatus = pvrr->pvrr_status;
if((rstatus = val2str(pvrstatus, recstatustxt)) != NULL)
- tcp_qprintf(tq, "Recording status: %s<br>", rstatus);
+ htsbuf_qprintf(hq, "Recording status: %s<br>", rstatus);
- tcp_qprintf(tq, "<form method=\"post\" action=\"/pvrinfo/%d\">",
+ htsbuf_qprintf(hq, "<form method=\"post\" action=\"/pvrinfo/%d\">",
pvrr->pvrr_ref);
switch(pvrstatus) {
case HTSTV_PVR_STATUS_SCHEDULED:
- tcp_qprintf(tq, "<input type=\"submit\" "
+ htsbuf_qprintf(hq, "<input type=\"submit\" "
"name=\"clear\" value=\"Remove from schedule\">");
break;
case HTSTV_PVR_STATUS_RECORDING:
- tcp_qprintf(tq, "<input type=\"submit\" "
+ htsbuf_qprintf(hq, "<input type=\"submit\" "
"name=\"cancel\" value=\"Cancel recording\">");
break;
case HTSTV_PVR_STATUS_DONE:
- tcp_qprintf(tq, "<input type=\"submit\" "
+ htsbuf_qprintf(hq, "<input type=\"submit\" "
"name=\"clear\" value=\"Remove from log\">");
break;
default:
- tcp_qprintf(tq, "<input type=\"submit\" "
+ htsbuf_qprintf(hq, "<input type=\"submit\" "
"name=\"clear\" value=\"Clear error status\">");
break;
}
- tcp_qprintf(tq, "</form>");
- tcp_qprintf(tq, "%s", pvrr->pvrr_desc);
+ htsbuf_qprintf(hq, "</form>");
+ htsbuf_qprintf(hq, "%s", pvrr->pvrr_desc);
- tcp_qprintf(tq, "<hr><a href=\"/simple.html\">New search</a><br>");
- tcp_qprintf(tq, "</body></html>");
+ htsbuf_qprintf(hq, "<hr><a href=\"/simple.html\">New search</a><br>");
+ htsbuf_qprintf(hq, "</body></html>");
http_output_html(hc, hr);
return 0;
}
tffm_fifo_t *tf = xs->xs_fifo;
xbmsp_t *xbmsp = xs->xs_xbmsp;
uint32_t msgid = xs->xs_pending_read_msgid;
- tcp_queue_t tq;
+ htsbuf_queue_t hq;
int rem, tlen, len = xs->xs_pending_read_size;
uint8_t buf[13];
tffm_fifo_pkt_t *pkt, *n;
buf[11] = len >> 8;
buf[12] = len;
- tcp_init_queue(&tq, -1);
- tcp_qput(&tq, buf, 13);
+ htsbuf_queue_init(&hq, 0);
+ htsbuf_append(&hq, buf, 13);
while(len > 0) {
pkt = TAILQ_FIRST(&tf->tf_pktq);
if(len >= pkt->tfp_pktsize) {
/* Consume entire packet */
- tcp_qput(&tq, pkt->tfp_buf, pkt->tfp_pktsize);
+ htsbuf_append(&hq, pkt->tfp_buf, pkt->tfp_pktsize);
} else {
/* Partial, create new packet at front with remaining data */
- tcp_qput(&tq, pkt->tfp_buf, len);
+ htsbuf_append(&hq, pkt->tfp_buf, len);
rem = pkt->tfp_pktsize - len;
n = malloc(sizeof(tffm_fifo_pkt_t) + rem);
n->tfp_pktsize = rem;
xs->xs_pending_read_size = 0;
xs->xs_pending_read_msgid = 0;
- tcp_output_queue(&xbmsp->xbmsp_tcp_session, NULL, &tq);
+ tcp_output_queue(&xbmsp->xbmsp_tcp_session, 0, &hq);
}
uint8_t *payload, int payloadlen)
{
uint8_t buf[9];
- tcp_queue_t tq;
+ htsbuf_queue_t hq;
int tlen = payloadlen + 5;
buf[7] = msgid >> 8;
buf[8] = msgid;
- tcp_init_queue(&tq, -1);
- tcp_qput(&tq, buf, 9);
+ htsbuf_queue_init(&hq, 0);
+ htsbuf_append(&hq, buf, 9);
if(payloadlen > 0) {
if(payload == NULL) {
payload = alloca(payloadlen);
memset(payload, 0, payloadlen);
}
- tcp_qput(&tq, payload, payloadlen);
+ htsbuf_append(&hq, payload, payloadlen);
}
- tcp_output_queue(&xbmsp->xbmsp_tcp_session, NULL, &tq);
+ tcp_output_queue(&xbmsp->xbmsp_tcp_session, 0, &hq);
}