diff --git a/ajaxui/ajaxui.c b/ajaxui/ajaxui.c index 42596baf..5340b82e 100644 --- a/ajaxui/ajaxui.c +++ b/ajaxui/ajaxui.c @@ -80,35 +80,35 @@ ajaxui_escape_apostrophe(const char *content) * */ 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, "\r\n"); } @@ -133,7 +133,7 @@ ajax_generate_select_functions(tcp_queue_t *tq, const char *fprefix, * 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; @@ -147,19 +147,19 @@ ajax_table_top(ajax_table_t *t, http_connection_t *hc, tcp_queue_t *tq, 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, "
"); + htsbuf_qprintf(hq, "
"); - tcp_qprintf(tq, "
"); + htsbuf_qprintf(hq, "
"); for(i = 0; i < n; i++) - tcp_qprintf(tq, "
%s
", + htsbuf_qprintf(hq, "
%s
", t->csize[i], *names[i] ? names[i]: " "); - tcp_qprintf(tq, "

\r\n"); + htsbuf_qprintf(hq, "

\r\n"); } /** @@ -170,7 +170,7 @@ ajax_table_row_start(ajax_table_t *t, const char *id) { t->rowid = id; t->rowcol = !t->rowcol; - tcp_qprintf(t->tq, "%s
", + htsbuf_qprintf(t->hq, "%s
", t->inrow ? "
\r\n" : "", t->rowcol ? "background: #fff; " : ""); t->inrow = 1; @@ -183,7 +183,7 @@ ajax_table_row_start(ajax_table_t *t, const char *id) void ajax_table_subrow_start(ajax_table_t *t) { - tcp_qprintf(t->tq, "
"); + htsbuf_qprintf(t->hq, "
"); t->curcol = 0; } @@ -194,7 +194,7 @@ ajax_table_subrow_start(ajax_table_t *t) void ajax_table_subrow_end(ajax_table_t *t) { - tcp_qprintf(t->tq, "
"); + htsbuf_qprintf(t->hq, "
"); t->curcol = 0; } @@ -208,7 +208,7 @@ ajax_table_details_start(ajax_table_t *t) assert(t->inrow == 1); t->inrow = 0; /* Extra info */ - tcp_qprintf(t->tq, "
", + htsbuf_qprintf(t->hq, "
", t->rowid, t->rowcol ? "background: #fff; " : ""); } @@ -219,7 +219,7 @@ void ajax_table_details_end(ajax_table_t *t) { /* Extra info */ - tcp_qprintf(t->tq, "
"); + htsbuf_qprintf(t->hq, "
"); } @@ -233,23 +233,23 @@ ajax_table_cell(ajax_table_t *t, const char *id, const char *fmt, ...) va_start(ap, fmt); if(t->rowid && id) { - tcp_qprintf(t->tq, "
rowid); + htsbuf_qprintf(t->hq, "
rowid); } else { - tcp_qprintf(t->tq, "hq, "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, "
"); + htsbuf_qprintf(t->hq, "
"); } /** @@ -282,14 +282,14 @@ ajax_table_cell_checkbox(ajax_table_t *t) void ajax_table_bottom(ajax_table_t *t) { - tcp_qprintf(t->tq, "%s
", t->inrow ? "" : ""); + htsbuf_qprintf(t->hq, "%s", t->inrow ? "" : ""); } /** * 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]; @@ -307,7 +307,7 @@ ajax_box_begin(tcp_queue_t *tq, ajax_box_t type, switch(type) { case AJAX_BOX_SIDEBOX: - tcp_qprintf(tq, + htsbuf_qprintf(hq, "
" "

%s

\r\n" "
", @@ -315,7 +315,7 @@ ajax_box_begin(tcp_queue_t *tq, ajax_box_t type, break; case AJAX_BOX_FILLED: - tcp_qprintf(tq, + htsbuf_qprintf(hq, "
" "" "" @@ -328,7 +328,7 @@ ajax_box_begin(tcp_queue_t *tq, ajax_box_t type, break; case AJAX_BOX_BORDER: - tcp_qprintf(tq, + htsbuf_qprintf(hq, "
" "" "" @@ -345,15 +345,15 @@ ajax_box_begin(tcp_queue_t *tq, ajax_box_t type, * 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,"
"); + htsbuf_qprintf(hq,"
"); break; case AJAX_BOX_FILLED: - tcp_qprintf(tq, + htsbuf_qprintf(hq, "" "" "" @@ -365,7 +365,7 @@ ajax_box_end(tcp_queue_t *tq, ajax_box_t type) break; case AJAX_BOX_BORDER: - tcp_qprintf(tq, + htsbuf_qprintf(hq, "" "" "" @@ -381,19 +381,19 @@ ajax_box_end(tcp_queue_t *tq, ajax_box_t type) * */ 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, "\r\n"); } @@ -404,22 +404,22 @@ ajax_js(tcp_queue_t *tq, const char *fmt, ...) * 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, "
    "); + htsbuf_qprintf(hq, "
      "); for(i = 0; i < num; i++) { - tcp_qprintf(tq, + htsbuf_qprintf(hq, "" "%s" "", cur == i ? " style=\"font-weight:bold;\"" : "", name, i, vec[i]); } - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(hq, "
"); } @@ -427,29 +427,29 @@ ajax_menu_bar_from_array(tcp_queue_t *tq, const char *name, * */ 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, "%s", innerhtml); + htsbuf_qprintf(hq, "%s", 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, ""); + htsbuf_vqprintf(hq, code, ap); + htsbuf_qprintf(hq, "\">"); } @@ -464,7 +464,7 @@ ajax_page_titlebar(http_connection_t *hc, http_reply_t *hr, 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; @@ -478,16 +478,16 @@ ajax_page_titlebar(http_connection_t *hc, http_reply_t *hr, 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, "
"); - tcp_qprintf(tq, "
"); + htsbuf_qprintf(hq, "
"); + htsbuf_qprintf(hq, "
"); - ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, "About"); + ajax_box_begin(hq, AJAX_BOX_SIDEBOX, NULL, NULL, "About"); - tcp_qprintf(tq, "
"); + htsbuf_qprintf(hq, "
"); - tcp_qprintf(tq, + htsbuf_qprintf(hq, "

HTS / Tvheadend

" "

(c) 2006-2008 Andreas \303\226man

" "

Latest release and information is available at:

" @@ -504,10 +504,10 @@ ajax_about_tab(http_connection_t *hc, http_reply_t *hr) "

FFmpeg

" ); - tcp_qprintf(tq, "
"); - ajax_box_end(tq, AJAX_BOX_SIDEBOX); - tcp_qprintf(tq, "
"); - tcp_qprintf(tq, "
"); + htsbuf_qprintf(hq, "
"); + ajax_box_end(hq, AJAX_BOX_SIDEBOX); + htsbuf_qprintf(hq, ""); + htsbuf_qprintf(hq, "
"); http_output_html(hc, hr); return 0; @@ -556,9 +556,9 @@ static int 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, "" /* @@ -589,13 +589,13 @@ ajax_page_root(http_connection_t *hc, http_reply_t *hr, ""); - tcp_qprintf(tq, "
"); + htsbuf_qprintf(hq, "
"); - tcp_qprintf(tq, "
"); + htsbuf_qprintf(hq, "
"); - 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, "
" "
" "Tvheadend (%s)" @@ -607,20 +607,20 @@ ajax_page_root(http_connection_t *hc, http_reply_t *hr, "
", 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, "
"); + htsbuf_qprintf(hq, "
"); - ajax_js(tq, "switchtab('top', '0')"); + ajax_js(hq, "switchtab('top', '0')"); #if 0 - tcp_qprintf(tq, "
"); + htsbuf_qprintf(hq, "
"); - 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, "
"); + htsbuf_qprintf(hq, "
"); http_output_html(hc, hr); return 0; diff --git a/ajaxui/ajaxui.h b/ajaxui/ajaxui.h index b84f5edf..3f59d859 100644 --- a/ajaxui/ajaxui.h +++ b/ajaxui/ajaxui.h @@ -32,10 +32,10 @@ typedef enum { } 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); @@ -47,11 +47,11 @@ typedef struct { 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, ...); @@ -66,7 +66,7 @@ void ajax_table_subrow_end(ajax_table_t *t); -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); @@ -83,7 +83,7 @@ void ajaxui_start(void); 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); @@ -106,18 +106,19 @@ void ajax_config_cwc_init(void); 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); diff --git a/ajaxui/ajaxui_channels.c b/ajaxui/ajaxui_channels.c index fd870128..4e1b9dcc 100644 --- a/ajaxui/ajaxui_channels.c +++ b/ajaxui/ajaxui_channels.c @@ -35,11 +35,11 @@ #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, "
    "); + htsbuf_qprintf(tq, "
      "); TAILQ_FOREACH(tcg, &all_channel_groups, tcg_global_link) { if(tcg->tcg_hidden) @@ -48,14 +48,14 @@ ajax_channelgroupmenu_content(tcp_queue_t *tq, int current) if(current < 1) current = tcg->tcg_tag; - tcp_qprintf(tq, + htsbuf_qprintf(tq, "" "%s" "", current == tcg->tcg_tag ? " style=\"font-weight:bold;\"" : "", tcg->tcg_tag, tcg->tcg_name); } - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
"); } @@ -66,7 +66,7 @@ static int 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; @@ -78,36 +78,36 @@ ajax_channelgroup_menu(http_connection_t *hc, http_reply_t *hr, 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, "
", + htsbuf_qprintf(tq, "
", 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, "
" "%02d:%02d-%02d:%02d" "
", a.tm_hour, a.tm_min, b.tm_hour, b.tm_min); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
" "%s" "
", e->e_title); - tcp_qprintf(tq, "
"); + htsbuf_qprintf(tq, "
"); } 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; @@ -131,7 +131,7 @@ ajax_channel_tab(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; char dispname[20]; @@ -147,7 +147,7 @@ ajax_channel_tab(http_connection_t *hc, http_reply_t *hr, nchs++; - tcp_qprintf(tq, "
"); + htsbuf_qprintf(tq, "
"); snprintf(dispname, sizeof(dispname), "%s", ch->ch_name); strcpy(dispname + sizeof(dispname) - 4, "..."); @@ -156,43 +156,43 @@ ajax_channel_tab(http_connection_t *hc, http_reply_t *hr, /* inner */ - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
"); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
"); if(ch->ch_icon != NULL) { - tcp_qprintf(tq, "", + htsbuf_qprintf(tq, "", ch->ch_icon); } - tcp_qprintf(tq, "
"); + htsbuf_qprintf(tq, "
"); - tcp_qprintf(tq, "
"); + htsbuf_qprintf(tq, "
"); si = (struct sockaddr_in *)&hc->hc_tcp_session.tcp_self_addr; - tcp_qprintf(tq, + htsbuf_qprintf(tq, "Stream", inet_ntoa(si->sin_addr), ntohs(si->sin_port), ch->ch_sname); - tcp_qprintf(tq, "
"); - tcp_qprintf(tq, "
"); + htsbuf_qprintf(tq, "
"); + htsbuf_qprintf(tq, "
"); - tcp_qprintf(tq, "
", ch->ch_tag); + htsbuf_qprintf(tq, "
", ch->ch_tag); ajax_list_events(tq, ch, 3); - tcp_qprintf(tq, "
"); + htsbuf_qprintf(tq, "
"); ajax_box_end(tq, AJAX_BOX_SIDEBOX); - tcp_qprintf(tq, "
"); + htsbuf_qprintf(tq, ""); } if(nchs == 0) - tcp_qprintf(tq, "
" + htsbuf_qprintf(tq, "
" "No channels in this group
"); http_output_html(hc, hr); @@ -211,14 +211,14 @@ ajax_channel_tab(http_connection_t *hc, http_reply_t *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, "
"); + htsbuf_qprintf(tq, "
"); - tcp_qprintf(tq, + htsbuf_qprintf(tq, ""); diff --git a/ajaxui/ajaxui_config.c b/ajaxui/ajaxui_config.c index 10d06c56..9397bf72 100644 --- a/ajaxui/ajaxui_config.c +++ b/ajaxui/ajaxui_config.c @@ -52,7 +52,7 @@ static int 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; @@ -109,18 +109,18 @@ ajax_config_dispatch(http_connection_t *hc, http_reply_t *hr, 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, "
"); + htsbuf_qprintf(tq, "
"); - tcp_qprintf(tq, + htsbuf_qprintf(tq, ""); - + http_output_html(hc, hr); return 0; } diff --git a/ajaxui/ajaxui_config_access.c b/ajaxui/ajaxui_config_access.c index ad907363..f908b159 100644 --- a/ajaxui/ajaxui_config_access.c +++ b/ajaxui/ajaxui_config_access.c @@ -51,26 +51,26 @@ static struct strtab accesstypetab[] = { 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, "
"); + htsbuf_qprintf(tq, "
"); ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, "Access control"); - tcp_qprintf(tq, "
"); + htsbuf_qprintf(tq, "
"); ajax_js(tq, "new Ajax.Updater('alist', '/ajax/accesslist', " "{method: 'get', evalScripts: true});"); - tcp_qprintf(tq, "
"); + htsbuf_qprintf(tq, "
"); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
" "
" "" @@ -80,11 +80,11 @@ ajax_config_access_tab(http_connection_t *hc, http_reply_t *hr) "
" "
"); - tcp_qprintf(tq, "
\r\n"); + htsbuf_qprintf(tq, "
\r\n"); ajax_box_end(tq, AJAX_BOX_SIDEBOX); - tcp_qprintf(tq, "
"); + htsbuf_qprintf(tq, "
"); http_output_html(hc, hr); return 0; } @@ -109,7 +109,7 @@ static int 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]; @@ -173,23 +173,23 @@ static int 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"); } @@ -207,7 +207,7 @@ static int 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; @@ -246,7 +246,7 @@ static int 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; @@ -258,7 +258,7 @@ ajax_accessdel(http_connection_t *hc, http_reply_t *hr, access_delete(ae); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "new Ajax.Updater('alist', '/ajax/accesslist', " "{method: 'get', evalScripts: true});\r\n"); @@ -275,7 +275,7 @@ static int 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; @@ -290,7 +290,7 @@ ajax_accesssetpw(http_connection_t *hc, http_reply_t *hr, access_save(); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "$('password_%d').innerHTML= '" "", tcg->tcg_tag); + htsbuf_qprintf(tq, "
  • ", tcg->tcg_tag); ajax_box_begin(tq, AJAX_BOX_BORDER, NULL, NULL, NULL); - tcp_qprintf(tq, "
  • "); + htsbuf_qprintf(tq, ""); } /** @@ -77,7 +77,7 @@ ajax_chgroup_updateorder(http_connection_t *hc, http_reply_t *hr, 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) { @@ -91,7 +91,7 @@ ajax_chgroup_updateorder(http_connection_t *hc, http_reply_t *hr, channel_group_settings_write(); - tcp_qprintf(tq, "Updated on server"); + htsbuf_qprintf(tq, "Updated on server"); ajax_js(tq, "Effect.Fade('updatedok')"); http_output_html(hc, hr); return 0; @@ -107,7 +107,7 @@ ajax_chgroup_add(http_connection_t *hc, http_reply_t *hr, 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) { @@ -147,7 +147,7 @@ ajax_chgroup_del(http_connection_t *hc, http_reply_t *hr, 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) @@ -156,7 +156,7 @@ ajax_chgroup_del(http_connection_t *hc, http_reply_t *hr, 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); @@ -171,18 +171,18 @@ ajax_chgroup_del(http_connection_t *hc, http_reply_t *hr, 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, "
    "); + htsbuf_qprintf(tq, "
    "); ajax_box_begin(tq, AJAX_BOX_SIDEBOX, "channelgroups", NULL, "Channel groups"); - tcp_qprintf(tq, "
    "); - tcp_qprintf(tq, "
      "); + htsbuf_qprintf(tq, "
        "); TAILQ_FOREACH(tcg, &all_channel_groups, tcg_global_link) { if(tcg->tcg_hidden) @@ -190,7 +190,7 @@ ajax_config_channels_tab(http_connection_t *hc, http_reply_t *hr) ajax_chgroup_build(tq, tcg); } - tcp_qprintf(tq, "
      "); + htsbuf_qprintf(tq, "
    "); ajax_js(tq, "Sortable.create(\"channelgrouplist\", " "{onUpdate:function(){updatelistonserver(" @@ -203,11 +203,11 @@ ajax_config_channels_tab(http_connection_t *hc, http_reply_t *hr) * Add new group */ - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); ajax_box_begin(tq, AJAX_BOX_BORDER, NULL, NULL, NULL); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "
    " "" @@ -221,13 +221,13 @@ ajax_config_channels_tab(http_connection_t *hc, http_reply_t *hr) ajax_box_end(tq, AJAX_BOX_BORDER); ajax_box_end(tq, AJAX_BOX_SIDEBOX); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    "); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    "); @@ -242,7 +242,7 @@ static int 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; @@ -253,49 +253,49 @@ ajax_chgroup_editor(http_connection_t *hc, http_reply_t *hr, if(remain == NULL || (tcg = channel_group_by_tag(atoi(remain))) == NULL) return HTTP_STATUS_BAD_REQUEST; - tcp_qprintf(tq, "\r\n"); @@ -345,41 +345,41 @@ ajax_chgroup_editor(http_connection_t *hc, http_reply_t *hr, } ajax_table_bottom(&ta); - tcp_qprintf(tq, "
    \r\n"); - tcp_qprintf(tq, "
    \r\n"); + htsbuf_qprintf(tq, "
    "); 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, "
    \r\n"); + htsbuf_qprintf(tq, "
    \r\n"); - tcp_qprintf(tq, "
    \r\n"); + htsbuf_qprintf(tq, "
    \r\n"); - tcp_qprintf(tq, "
    "); ajax_button(tq, "Delete all selected...", "select_do('delete', '%d', 0, true);", tcg->tcg_tag); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    "); - tcp_qprintf(tq, "
    "); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); + htsbuf_qprintf(tq, ""); + htsbuf_qprintf(tq, ""); ajax_box_end(tq, AJAX_BOX_SIDEBOX); @@ -412,7 +412,7 @@ static int 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; @@ -425,25 +425,25 @@ ajax_cheditor(http_connection_t *hc, http_reply_t *hr, ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, ch->ch_name); if(ch->ch_icon != NULL) { - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "
    ", ch->ch_icon); } - tcp_qprintf(tq, "
    Sources:
    "); + htsbuf_qprintf(tq, "
    Sources:
    "); LIST_FOREACH(t, &ch->ch_transports, tht_ch_link) { ajax_box_begin(tq, AJAX_BOX_BORDER, NULL, NULL, NULL); - tcp_qprintf(tq, "
    "); - tcp_qprintf(tq, "
    %s
    ", + htsbuf_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    %s
    ", val2str(t->tht_type, sourcetypetab) ?: "???"); - tcp_qprintf(tq, "
    \"%s\"%s
    ", + htsbuf_qprintf(tq, "
    \"%s\"%s
    ", t->tht_svcname, t->tht_scrambled ? " - (scrambled)" : ""); s = t->tht_sourcename ? t->tht_sourcename(t) : NULL; - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "tht_identifier); if(s != NULL) - tcp_qprintf(tq, "
    %s
    ", + htsbuf_qprintf(tq, "
    %s
    ", s); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); ajax_box_end(tq, AJAX_BOX_BORDER); } - tcp_qprintf(tq, "
    \r\n"); + htsbuf_qprintf(tq, "
    \r\n"); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "", ch->ch_tag, ch->ch_name); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "", ch->ch_tag, ch->ch_name); - tcp_qprintf(tq, + htsbuf_qprintf(tq, ""); - tcp_qprintf(tq, "
    "); - tcp_qprintf(tq, "
    \r\n"); + htsbuf_qprintf(tq, ""); + htsbuf_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    \r\n"); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "Commercial detection:
    " "
    " @@ -504,13 +504,13 @@ ajax_cheditor(http_connection_t *hc, http_reply_t *hr, ch->ch_tag); for(i = 0; i < sizeof(cdlongname) / sizeof(cdlongname[0]); i++) { - tcp_qprintf(tq, "", + htsbuf_qprintf(tq, "", cdlongname[i].val == ch->ch_commercial_detection ? "selected " : "", cdlongname[i].val, cdlongname[i].str); } - tcp_qprintf(tq, "
    "); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, ""); + htsbuf_qprintf(tq, ""); ajax_box_end(tq, AJAX_BOX_SIDEBOX); @@ -525,7 +525,7 @@ static int 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; @@ -550,7 +550,7 @@ ajax_changegroup(http_connection_t *hc, http_reply_t *hr, channel_set_group(ch, tcg); } - tcp_qprintf(tq, + htsbuf_qprintf(tq, "$('cheditortab').innerHTML=''; " "new Ajax.Updater('groupeditortab', " "'/ajax/chgroup_editor/%s', " @@ -591,7 +591,7 @@ static int 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; @@ -602,15 +602,15 @@ ajax_chrename(http_connection_t *hc, http_reply_t *hr, 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", @@ -629,7 +629,7 @@ static int 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; @@ -640,13 +640,13 @@ ajax_chdelete(http_connection_t *hc, http_reply_t *hr, 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; @@ -659,7 +659,7 @@ static int 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; @@ -676,13 +676,13 @@ ajax_chmerge(http_connection_t *hc, http_reply_t *hr, 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; @@ -695,7 +695,7 @@ static int 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; @@ -711,7 +711,7 @@ ajax_chdeletemulti(http_connection_t *hc, http_reply_t *hr, channel_delete(ch); } - tcp_qprintf(tq, + htsbuf_qprintf(tq, "$('cheditortab').innerHTML=''; " "new Ajax.Updater('groupeditortab', " "'/ajax/chgroup_editor/%s', " diff --git a/ajaxui/ajaxui_config_cwc.c b/ajaxui/ajaxui_config_cwc.c index a386fee1..33163d59 100644 --- a/ajaxui/ajaxui_config_cwc.c +++ b/ajaxui/ajaxui_config_cwc.c @@ -35,26 +35,26 @@ 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, "
    "); + htsbuf_qprintf(q, "
    "); - ajax_js(tq, + ajax_js(q, "new Ajax.Updater('cwclist', '/ajax/cwclist', " "{method: 'get', evalScripts: true});"); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(q, "
    "); - tcp_qprintf(tq, + htsbuf_qprintf(q, "
    " "
    Hostname:
    " "
    " "" "
    "); - tcp_qprintf(tq, + htsbuf_qprintf(q, "
    " "
    Port:
    " "
    " @@ -62,28 +62,28 @@ ajax_config_cwc_tab(http_connection_t *hc, http_reply_t *hr) "
    "); - tcp_qprintf(tq, + htsbuf_qprintf(q, "
    " "
    Username:
    " "
    " "" "
    "); - tcp_qprintf(tq, + htsbuf_qprintf(q, "
    " "
    Password:
    " "
    " "" "
    "); - tcp_qprintf(tq, + htsbuf_qprintf(q, "
    " "
    DES-key:
    " "
    " "" "
    "); - tcp_qprintf(tq, + htsbuf_qprintf(q, "
    " ""); - tcp_qprintf(tq, "
    \r\n"); + htsbuf_qprintf(q, "
    \r\n"); - ajax_box_end(tq, AJAX_BOX_SIDEBOX); + ajax_box_end(q, AJAX_BOX_SIDEBOX); - tcp_qprintf(tq, ""); + htsbuf_qprintf(q, ""); http_output_html(hc, hr); return 0; } @@ -113,12 +113,12 @@ static int 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", @@ -166,7 +166,7 @@ static int 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"), @@ -177,15 +177,15 @@ ajax_cwcadd(http_connection_t *hc, http_reply_t *hr, "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});"); } @@ -202,7 +202,7 @@ static int 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; @@ -213,7 +213,7 @@ ajax_cwcdel(http_connection_t *hc, http_reply_t *hr, return HTTP_STATUS_BAD_REQUEST; cwc_delete(cwc); - tcp_qprintf(tq, + htsbuf_qprintf(q, "new Ajax.Updater('cwclist', '/ajax/cwclist', " "{method: 'get', evalScripts: true});"); @@ -228,7 +228,7 @@ static int 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; diff --git a/ajaxui/ajaxui_config_dvb.c b/ajaxui/ajaxui_config_dvb.c index 79180db1..8da3a784 100644 --- a/ajaxui/ajaxui_config_dvb.c +++ b/ajaxui/ajaxui_config_dvb.c @@ -42,10 +42,10 @@ 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, "", name); + htsbuf_qprintf(tq, "", name); } /** @@ -96,7 +96,7 @@ static int 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]; @@ -108,14 +108,14 @@ ajax_adaptersummary(http_connection_t *hc, http_reply_t *hr, ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, dispname); - tcp_qprintf(tq, "
    Device:
    " + htsbuf_qprintf(tq, "
    Device:
    " "
    %s
    ", tda->tda_rootpath ?: "Not present"); - tcp_qprintf(tq, "
    Type:
    " + htsbuf_qprintf(tq, "
    Type:
    " "
    %s
    ", dvb_adaptertype_to_str(tda->tda_type)); - tcp_qprintf(tq, "
    " + htsbuf_qprintf(tq, "
    " "hr_tq; + htsbuf_queue_t *tq = &hr->hr_q; th_dvb_adapter_t *tda; - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); if(TAILQ_FIRST(&dvb_adapters) == NULL) { - tcp_qprintf(tq, "
    " + htsbuf_qprintf(tq, "
    " "No adapters found
    "); } TAILQ_FOREACH(tda, &dvb_adapters, tda_global_link) { - tcp_qprintf(tq, "
    ", tda->tda_identifier); @@ -156,8 +156,8 @@ ajax_config_dvb_tab(http_connection_t *hc, http_reply_t *hr) tda->tda_identifier, tda->tda_identifier); } - tcp_qprintf(tq, "
    "); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); http_output_html(hc, hr); return 0; } @@ -171,7 +171,7 @@ static int 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; @@ -180,7 +180,7 @@ ajax_adaptereditor(http_connection_t *hc, http_reply_t *hr, ajax_box_begin(tq, AJAX_BOX_FILLED, NULL, NULL, NULL); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    %s
    ", tda->tda_identifier, tda->tda_displayname); @@ -189,11 +189,11 @@ ajax_adaptereditor(http_connection_t *hc, http_reply_t *hr, /* Type */ - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); - tcp_qprintf(tq, "
    Model:
    " + htsbuf_qprintf(tq, "
    Model:
    " "
    %s (%s)
    ", tda->tda_fe_info ? tda->tda_fe_info->name : "", dvb_adaptertype_to_str(tda->tda_type)); @@ -203,7 +203,7 @@ ajax_adaptereditor(http_connection_t *hc, http_reply_t *hr, if(tda->tda_fe_info != NULL) { s = tda->tda_type == FE_QPSK ? "kHz" : "Hz"; - tcp_qprintf(tq, "
    Freq. Range:
    " + htsbuf_qprintf(tq, "
    Freq. Range:
    " "
    %s - %s %s, in steps of %s %s
    ", nicenum(tda->tda_fe_info->frequency_min), nicenum(tda->tda_fe_info->frequency_max), @@ -213,70 +213,70 @@ ajax_adaptereditor(http_connection_t *hc, http_reply_t *hr, if(tda->tda_fe_info->symbol_rate_min) { - tcp_qprintf(tq, "
    Symbolrate:
    " + htsbuf_qprintf(tq, "
    Symbolrate:
    " "
    %s - %s Baud
    ", nicenum(tda->tda_fe_info->symbol_rate_min), nicenum(tda->tda_fe_info->symbol_rate_max)); } /* Capabilities */ - // tcp_qprintf(tq, "
    Capabilities:
    "); + // htsbuf_qprintf(tq, "
    Capabilities:
    "); } - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "", tda->tda_identifier, tda->tda_displayname); if(tda->tda_rootpath == NULL) { - tcp_qprintf(tq, + htsbuf_qprintf(tq, "", tda->tda_identifier, tda->tda_displayname); } - // tcp_qprintf(tq, "
    "); + // htsbuf_qprintf(tq, "
    "); /* Clone adapter */ - // tcp_qprintf(tq, "
    "); - tcp_qprintf(tq, + // htsbuf_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); /* Muxes and transports */ - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, "Multiplexes"); - tcp_qprintf(tq, "
    ", + htsbuf_qprintf(tq, "
    ", tda->tda_identifier); ajax_js(tq, @@ -285,12 +285,12 @@ ajax_adaptereditor(http_connection_t *hc, http_reply_t *hr, tda->tda_identifier, tda->tda_identifier); ajax_box_end(tq, AJAX_BOX_SIDEBOX); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); /* Div for displaying services */ - tcp_qprintf(tq, "
    "); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); http_output_html(hc, hr); return 0; @@ -304,7 +304,7 @@ static int 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; @@ -329,11 +329,11 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr, /* Manual configuration */ - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "Manual configuartion
    "); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "
    Frequency (%s):
    " "
    " @@ -348,7 +348,7 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr, if(fetype == FE_QAM || fetype == FE_QPSK) { - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "
    Symbolrate:
    " "
    " @@ -362,7 +362,7 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr, /* Bandwidth */ if(fetype == FE_OFDM) { - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "
    Bandwidth:
    " "
    "); + htsbuf_qprintf(tq, "
    "); snprintf(params + strlen(params), sizeof(params) - strlen(params), ", bw: $F('bw')"); @@ -382,7 +382,7 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr, if(fetype == FE_QAM || fetype == FE_OFDM) { - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "
    Constellation:
    " "
    "); + htsbuf_qprintf(tq, "
    "); snprintf(params + strlen(params), sizeof(params) - strlen(params), ", const: $F('const')"); @@ -405,7 +405,7 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr, /* FEC */ if(fetype == FE_QAM || fetype == FE_QPSK) { - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "
    FEC:
    " "
    "); + htsbuf_qprintf(tq, "
    "); snprintf(params + strlen(params), sizeof(params) - strlen(params), ", fec: $F('fec')"); } if(fetype == FE_QPSK) { - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "
    Polarisation:
    " "
    "); + htsbuf_qprintf(tq, ""); snprintf(params + strlen(params), sizeof(params) - strlen(params), ", pol: $F('pol')"); @@ -443,7 +443,7 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr, if(fetype == FE_OFDM) { - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "
    Transmission mode:
    " "
    "); + htsbuf_qprintf(tq, ""); snprintf(params + strlen(params), sizeof(params) - strlen(params), ", tmode: $F('tmode')"); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "
    Guard interval:
    " "
    "); + htsbuf_qprintf(tq, ""); snprintf(params + strlen(params), sizeof(params) - strlen(params), ", guard: $F('guard')"); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "
    Hierarchy:
    " "
    "); + htsbuf_qprintf(tq, ""); snprintf(params + strlen(params), sizeof(params) - strlen(params), @@ -491,7 +491,7 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr, - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "
    FEC Hi:
    " "
    "); + htsbuf_qprintf(tq, ""); snprintf(params + strlen(params), sizeof(params) - strlen(params), ", fechi: $F('fechi')"); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "
    FEC Low:
    " "
    "); + htsbuf_qprintf(tq, ""); snprintf(params + strlen(params), sizeof(params) - strlen(params), ", feclo: $F('feclo')"); } - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "
    " "" "
    " "Preconfigured network
    "); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "
    "); + htsbuf_qprintf(tq, "
    "); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    "); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "
    " "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", @@ -646,7 +646,7 @@ ajax_adaptermuxlist(http_connection_t *hc, http_reply_t *hr, { 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; @@ -664,7 +664,7 @@ ajax_adaptermuxlist(http_connection_t *hc, http_reply_t *hr, nmuxes = tda->tda_muxes.entries; if(nmuxes == 0) { - tcp_qprintf(tq, "
    " + htsbuf_qprintf(tq, "
    " "No muxes configured
    "); } else { @@ -724,24 +724,24 @@ ajax_adaptermuxlist(http_connection_t *hc, http_reply_t *hr, ajax_table_bottom(&ta); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); 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, "
    \r\n"); + htsbuf_qprintf(tq, "
    \r\n"); } if(tda->tda_fe_info != NULL) { - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); ajax_button(tq, "Add new mux...", "new Ajax.Updater('servicepane', " "'/ajax/dvbadapteraddmux/%s', " "{method: 'get', evalScripts: true})\"", tda->tda_identifier); - tcp_qprintf(tq, "
    \r\n"); + htsbuf_qprintf(tq, "
    \r\n"); } http_output_html(hc, hr); return 0; @@ -768,7 +768,7 @@ ajax_dvbmuxeditor(http_connection_t *hc, http_reply_t *hr, 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; @@ -805,7 +805,7 @@ ajax_dvbmuxall(http_connection_t *hc, http_reply_t *hr, { 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; @@ -845,7 +845,7 @@ ajax_adapterdelmux(http_connection_t *hc, http_reply_t *hr, { 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) @@ -861,7 +861,7 @@ ajax_adapterdelmux(http_connection_t *hc, http_reply_t *hr, dvb_mux_destroy(tdmi); } - tcp_qprintf(tq, + htsbuf_qprintf(tq, "new Ajax.Updater('dvbadaptereditor', " "'/ajax/dvbadaptereditor/%s', " "{method: 'get', evalScripts: true});", @@ -880,7 +880,7 @@ ajax_adapterrename(http_connection_t *hc, http_reply_t *hr, { 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) @@ -893,11 +893,11 @@ ajax_adapterrename(http_connection_t *hc, http_reply_t *hr, 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); @@ -914,14 +914,14 @@ static int 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; @@ -937,7 +937,7 @@ static int 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; @@ -951,10 +951,10 @@ ajax_dvbadapteraddnetwork(http_connection_t *hc, http_reply_t *hr, 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", @@ -972,7 +972,7 @@ static int 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; @@ -989,7 +989,7 @@ ajax_dvbadapterclone(http_connection_t *hc, http_reply_t *hr, 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); @@ -1006,15 +1006,15 @@ static int 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); diff --git a/ajaxui/ajaxui_config_transport.c b/ajaxui/ajaxui_config_transport.c index 2126bd22..a6f357a3 100644 --- a/ajaxui/ajaxui_config_transport.c +++ b/ajaxui/ajaxui_config_transport.c @@ -38,84 +38,84 @@ * */ 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, "\r\n"); /* Top */ - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, ""); ajax_table_top(&ta, hc, tq, (const char *[]){"Last status", "Crypto", @@ -158,22 +158,22 @@ ajax_transport_build_list(http_connection_t *hc, tcp_queue_t *tq, ajax_table_bottom(&ta); - tcp_qprintf(tq, "
    \r\n"); + htsbuf_qprintf(tq, "
    \r\n"); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); ajax_button(tq, "Select all", "select_all()"); ajax_button(tq, "Select none", "select_none()"); - // tcp_qprintf(tq, "
    \r\n"); - //tcp_qprintf(tq, "
    "); + // htsbuf_qprintf(tq, "
    \r\n"); + //htsbuf_qprintf(tq, "
    "); 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, "
    "); + htsbuf_qprintf(tq, "
    "); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, ""); return 0; } @@ -186,7 +186,7 @@ ajax_transport_rename_channel(http_connection_t *hc, http_reply_t *hr, { 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; @@ -239,7 +239,7 @@ ajax_transport_build_mapper_state(char *buf, size_t siz, th_transport_t *t, * */ 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]; @@ -249,7 +249,7 @@ ajax_map_unmap_channel(th_transport_t *t, tcp_queue_t *tq, int map) transport_unmap_channel(t); ajax_transport_build_mapper_state(buf, sizeof(buf), t, map); - tcp_qprintf(tq, "%s", buf); + htsbuf_qprintf(tq, "%s", buf); } @@ -261,7 +261,7 @@ ajax_transport_op(http_connection_t *hc, http_reply_t *hr, 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; diff --git a/ajaxui/ajaxui_config_xmltv.c b/ajaxui/ajaxui_config_xmltv.c index 4927d1f4..d5f96e14 100644 --- a/ajaxui/ajaxui_config_xmltv.c +++ b/ajaxui/ajaxui_config_xmltv.c @@ -43,23 +43,23 @@ 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, "
    "); + htsbuf_qprintf(tq, "
    "); switch(xmltv_globalstatus) { default: - tcp_qprintf(tq, "

    " + htsbuf_qprintf(tq, "

    " "XMLTV subsystem is not yet fully initialized, please retry " "in a few seconds

    "); http_output_html(hc, hr); return 0; case XMLTVSTATUS_FIND_GRABBERS_NOT_FOUND: - tcp_qprintf(tq, "

    " + htsbuf_qprintf(tq, "

    " "XMLTV subsystem can not initialize

    " "

    " "Make sure that the 'tv_find_grabbers' executable is in " @@ -71,7 +71,7 @@ ajax_config_xmltv_tab(http_connection_t *hc, http_reply_t *hr) break; } - tcp_qprintf(tq, "

    "); + htsbuf_qprintf(tq, "
    "); ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, "XMLTV grabbers"); @@ -97,11 +97,11 @@ ajax_config_xmltv_tab(http_connection_t *hc, http_reply_t *hr) ajax_box_end(tq, AJAX_BOX_SIDEBOX); - tcp_qprintf(tq, "
    " + htsbuf_qprintf(tq, "
    " "
    " "
    "); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); http_output_html(hc, hr); return 0; } @@ -110,52 +110,52 @@ ajax_config_xmltv_tab(http_connection_t *hc, http_reply_t *hr) * 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, "
    "); TAILQ_FOREACH(xc, &xg->xg_channels, xc_link) { - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    "); - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, "
    "); if(xc->xc_icon_url != NULL) { - tcp_qprintf(tq, + htsbuf_qprintf(tq, "", xc->xc_icon_url); } else { - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    " "No icon
    "); } - tcp_qprintf(tq, "
    "); /* iconbackdrop */ + htsbuf_qprintf(tq, "
    "); /* iconbackdrop */ - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    Name:
    " "
    %s (%s)
    ", xc->xc_displayname, xc->xc_name); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    Auto mapper:
    " "
    %s
    ", xc->xc_bestmatch ?: "(no channel)"); - tcp_qprintf(tq, + htsbuf_qprintf(tq, "
    Channel:
    " ""); - tcp_qprintf(tq, "

    \r\n"); + htsbuf_qprintf(tq, ""); + htsbuf_qprintf(tq, "

    \r\n"); } - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(tq, ""); } @@ -187,7 +187,7 @@ ajax_xmltvgrabber(http_connection_t *hc, http_reply_t *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) @@ -195,10 +195,10 @@ ajax_xmltvgrabber(http_connection_t *hc, http_reply_t *hr, ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, xg->xg_title); - tcp_qprintf(tq,"
    "); ajax_box_end(tq, AJAX_BOX_SIDEBOX); http_output_html(hc, hr); @@ -227,14 +227,14 @@ ajax_xmltvgrabbermode(http_connection_t *hc, http_reply_t *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); @@ -251,7 +251,7 @@ ajax_xmltvgrabberlist(http_connection_t *hc, http_reply_t *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; @@ -275,7 +275,7 @@ ajax_xmltvgrabberchmap(http_connection_t *hc, http_reply_t *hr, 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; diff --git a/ajaxui/ajaxui_mailbox.c b/ajaxui/ajaxui_mailbox.c index c9a056f8..f43203c2 100644 --- a/ajaxui/ajaxui_mailbox.c +++ b/ajaxui/ajaxui_mailbox.c @@ -155,7 +155,7 @@ ajax_mailbox_create(const char *id) * */ void -ajax_mailbox_start(tcp_queue_t *tq) +ajax_mailbox_start(htsbuf_queue_t *hq) { struct timeval tv; uint8_t sum[16]; @@ -181,7 +181,7 @@ ajax_mailbox_start(tcp_queue_t *tq) mbdebug("Generated mailbox %s\n", id); ajax_mailbox_create(id); - ajax_js(tq, "mailboxquery('%s')", id); + ajax_js(hq, "mailboxquery('%s')", id); } @@ -200,16 +200,17 @@ ajax_mailbox_reply(ajaxui_mailbox_t *amb, http_reply_t *hr) 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; diff --git a/ajaxui/ajaxui_mailbox.h b/ajaxui/ajaxui_mailbox.h index b9d7d587..5bf3a992 100644 --- a/ajaxui/ajaxui_mailbox.h +++ b/ajaxui/ajaxui_mailbox.h @@ -19,7 +19,7 @@ #ifndef AJAXUI_MAILBOX_H_ #define AJAXUI_MAILBOX_H_ -#include "tcp.h" +#include void ajax_mailbox_tdmi_state_change(th_dvb_mux_instance_t *tdmi); @@ -33,7 +33,7 @@ void ajax_mailbox_tdmi_services_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; diff --git a/cwc.c b/cwc.c index 14776c26..fa35580d 100644 --- a/cwc.c +++ b/cwc.c @@ -316,7 +316,7 @@ cwc_send_msg(cwc_t *cwc, const uint8_t *msg, size_t len, int sid) 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); diff --git a/htsp.c b/htsp.c index 24770a99..0ed1abbc 100644 --- a/htsp.c +++ b/htsp.c @@ -51,17 +51,18 @@ int 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; diff --git a/http.c b/http.c index 8463e125..4f5c0afb 100644 --- a/http.c +++ b/http.c @@ -156,7 +156,7 @@ http_destroy_reply(http_connection_t *hc, http_reply_t *hr) 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); } @@ -170,7 +170,7 @@ http_send_reply(http_connection_t *hc, http_reply_t *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) { @@ -219,12 +219,14 @@ http_send_reply(http_connection_t *hc, http_reply_t *hr) "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; } @@ -267,11 +269,11 @@ void 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, "\r\n" "\r\n" "%d %s\r\n" @@ -318,9 +320,9 @@ http_output_html(http_connection_t *hc, http_reply_t *hr) 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, "\r\n" "\r\n" "Redirect\r\n" @@ -349,7 +351,7 @@ http_exec(http_connection_t *hc, http_path_t *hp, char *remain, int err) /* 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; @@ -590,7 +592,7 @@ http_con_parse(void *aux, char *buf) 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: @@ -918,7 +920,7 @@ deliver_resource(http_connection_t *hc, http_reply_t *hr, { 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; } diff --git a/http.h b/http.h index 3a300843..b6be9ee9 100644 --- a/http.h +++ b/http.h @@ -63,7 +63,7 @@ typedef struct http_reply { const char *hr_encoding; const char *hr_content; - tcp_queue_t hr_tq; + htsbuf_queue_t hr_q; } http_reply_t; diff --git a/tcp.c b/tcp.c index c5652267..ada8a5b9 100644 --- a/tcp.c +++ b/tcp.c @@ -35,82 +35,6 @@ 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) @@ -186,34 +110,6 @@ tcp_line_read(tcp_session_t *ses, tcp_line_input_t *callback) } - -/** - * 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 @@ -222,23 +118,23 @@ tcp_flush_queue(tcp_queue_t *tq) 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; @@ -250,19 +146,17 @@ tcp_transmit(tcp_session_t *ses) 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; @@ -273,7 +167,7 @@ tcp_transmit(tcp_session_t *ses) ses->tcp_blocked = 1; } } - ses->tcp_q_current = q; + ses->tcp_q_current = hq; } /** @@ -281,25 +175,22 @@ tcp_transmit(tcp_session_t *ses) * 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; + htsbuf_queue_t *hq = &ses->tcp_q[!!hiprio]; + htsbuf_data_t *hd; - if(tq == NULL) - tq = &ses->tcp_q_low; - - 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); @@ -307,6 +198,21 @@ tcp_send_msg(tcp_session_t *ses, tcp_queue_t *tq, const void *data, return 0; } +/** + * + */ +void +tcp_printf(tcp_session_t *ses, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + + htsbuf_vqprintf(&ses->tcp_q[0], fmt, ap); + va_end(ap); + + if(!ses->tcp_blocked) + tcp_transmit(ses); +} /** * Move a tcp queue onto a session @@ -314,47 +220,21 @@ tcp_send_msg(tcp_session_t *ses, tcp_queue_t *tq, const void *data, * 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_output_queue(tcp_session_t *ses, int hiprio, htsbuf_queue_t *src) { - tcp_data_t *sd; - tcp_data_t *dd; - int l, s; + htsbuf_data_t *hd; + htsbuf_queue_t *dst = &ses->tcp_q[!!hiprio]; - if(dst == NULL) - dst = &ses->tcp_q_low; + 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); - while((sd = TAILQ_FIRST(&src->tq_messages)) != NULL) { - - 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); - - s = 0; /* accumulated size */ - while((sd = TAILQ_FIRST(&src->tq_messages)) != NULL) { - - if(sd->td_datalen + s > l) - break; - - 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); - } - - 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; } /** @@ -363,8 +243,8 @@ tcp_output_queue(tcp_session_t *ses, tcp_queue_t *dst, tcp_queue_t *src) 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); @@ -433,8 +313,8 @@ tcp_start_session(tcp_session_t *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)); diff --git a/tcp.h b/tcp.h index 95d5054b..25cebfff 100644 --- a/tcp.h +++ b/tcp.h @@ -19,20 +19,7 @@ #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 typedef enum { TCP_CONNECT, @@ -74,10 +61,9 @@ typedef struct tcp_session { /* 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 */ @@ -86,10 +72,6 @@ typedef struct tcp_session { } 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, @@ -101,18 +83,9 @@ int tcp_line_drain(tcp_session_t *ses, void *buf, int n); #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); @@ -121,4 +94,6 @@ void tcp_destroy_client(tcp_session_t *ses); 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_ */ diff --git a/webui/webui.c b/webui/webui.c index 00213073..674342f6 100644 --- a/webui/webui.c +++ b/webui/webui.c @@ -121,7 +121,7 @@ static int 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; @@ -131,18 +131,18 @@ page_simple(http_connection_t *hc, http_reply_t *hr, pvr_rec_t *pvrr, **pv; const char *rstatus; - tcp_qprintf(tq, ""); - tcp_qprintf(tq, ""); + htsbuf_qprintf(hq, ""); + htsbuf_qprintf(hq, ""); - tcp_qprintf(tq, "
    "); - tcp_qprintf(tq, "Event: "); + htsbuf_qprintf(hq, "Event: "); - tcp_qprintf(tq, ""); + htsbuf_qprintf(hq, "name=\"s\">"); + htsbuf_qprintf(hq, ""); - tcp_qprintf(tq, "

    "); + htsbuf_qprintf(hq, "
    "); if(s != NULL) { @@ -150,12 +150,12 @@ page_simple(http_connection_t *hc, http_reply_t *hr, c = epg_search(&events, s, NULL, NULL, NULL); if(c == -1) { - tcp_qprintf(tq, "Event title: Regular expression syntax error"); + htsbuf_qprintf(hq, "Event title: Regular expression syntax error"); } else if(c == 0) { - tcp_qprintf(tq, "No matching entries found"); + htsbuf_qprintf(hq, "No matching entries found"); } else { - tcp_qprintf(tq, "%d entries found", c); + htsbuf_qprintf(hq, "%d entries found", c); ev = alloca(c * sizeof(event_t *)); c = 0; @@ -166,10 +166,10 @@ page_simple(http_connection_t *hc, http_reply_t *hr, if(c > 25) { c = 25; - tcp_qprintf(tq, ", %d entries shown", c); + htsbuf_qprintf(hq, ", %d entries shown", c); } - tcp_qprintf(tq, ""); + htsbuf_qprintf(hq, ""); memset(&day, -1, sizeof(struct tm)); for(k = 0; k < c; k++) { @@ -182,7 +182,7 @@ page_simple(http_connection_t *hc, http_reply_t *hr, 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, "
    %s, %d/%d
    ", days[day.tm_wday], day.tm_mday, day.tm_mon + 1); } @@ -191,7 +191,7 @@ page_simple(http_connection_t *hc, http_reply_t *hr, rstatus = pvrr != NULL ? val2str(pvrr->pvrr_status, recstatustxt) : NULL; - tcp_qprintf(tq, + htsbuf_qprintf(hq, "
    " "%02d:%02d-%02d:%02d %s%s%s
    ", e->e_tag, @@ -200,17 +200,17 @@ page_simple(http_connection_t *hc, http_reply_t *hr, rstatus ? " " : "", rstatus ?: ""); } } - tcp_qprintf(tq, "
    "); + htsbuf_qprintf(hq, "
    "); } - tcp_qprintf(tq, "Recorder log:
    \n"); + htsbuf_qprintf(hq, "Recorder log:
    \n"); c = 0; LIST_FOREACH(pvrr, &pvrr_global_list, pvrr_global_link) c++; if(c == 0) { - tcp_qprintf(tq, "No entries
    "); + htsbuf_qprintf(hq, "No entries
    "); } pv = alloca(c * sizeof(pvr_rec_t *)); @@ -232,25 +232,25 @@ page_simple(http_connection_t *hc, http_reply_t *hr, 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, "
    %s, %d/%d
    ", + htsbuf_qprintf(hq, "
    %s, %d/%d
    ", days[day.tm_wday], day.tm_mday, day.tm_mon + 1); } rstatus = val2str(pvrr->pvrr_status, recstatustxt); - tcp_qprintf(tq, "", pvrr->pvrr_ref); + htsbuf_qprintf(hq, "", 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, ""); + htsbuf_qprintf(hq, ""); - tcp_qprintf(tq, "
    (%s)

    ", rstatus); + htsbuf_qprintf(hq, "
    (%s)

    ", rstatus); } - tcp_qprintf(tq, ""); + htsbuf_qprintf(hq, ""); http_output_html(hc, hr); return 0; } @@ -262,7 +262,7 @@ static int 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; @@ -284,55 +284,55 @@ page_einfo(http_connection_t *hc, http_reply_t *hr, pvr_abort(pvrr); } - tcp_qprintf(tq, ""); - tcp_qprintf(tq, ""); + htsbuf_qprintf(hq, ""); + htsbuf_qprintf(hq, ""); 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
    ", 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, "
    \"%s\": \"%s\"

    ", + htsbuf_qprintf(hq, "
    \"%s\": \"%s\"

    ", 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
    ", rstatus); + htsbuf_qprintf(hq, "Recording status: %s
    ", rstatus); - tcp_qprintf(tq, "
    ", e->e_tag); + htsbuf_qprintf(hq, "", e->e_tag); switch(pvrstatus) { case HTSTV_PVR_STATUS_SCHEDULED: - tcp_qprintf(tq, ""); break; case HTSTV_PVR_STATUS_RECORDING: - tcp_qprintf(tq, ""); break; case HTSTV_PVR_STATUS_NONE: - tcp_qprintf(tq, ""); break; default: - tcp_qprintf(tq, ""); break; } - tcp_qprintf(tq, "
    "); - tcp_qprintf(tq, "%s", e->e_desc); + htsbuf_qprintf(hq, ""); + htsbuf_qprintf(hq, "%s", e->e_desc); - tcp_qprintf(tq, "
    New search
    "); - tcp_qprintf(tq, ""); + htsbuf_qprintf(hq, "
    New search
    "); + htsbuf_qprintf(hq, ""); http_output_html(hc, hr); return 0; } @@ -345,7 +345,7 @@ static int 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; @@ -364,56 +364,56 @@ page_pvrinfo(http_connection_t *hc, http_reply_t *hr, pvr_abort(pvrr); } - tcp_qprintf(tq, ""); - tcp_qprintf(tq, ""); + htsbuf_qprintf(hq, ""); + htsbuf_qprintf(hq, ""); 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
    ", 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, "
    \"%s\": \"%s\"

    ", + htsbuf_qprintf(hq, "
    \"%s\": \"%s\"

    ", pvrr->pvrr_channel->ch_name, pvrr->pvrr_title); pvrstatus = pvrr->pvrr_status; if((rstatus = val2str(pvrstatus, recstatustxt)) != NULL) - tcp_qprintf(tq, "Recording status: %s
    ", rstatus); + htsbuf_qprintf(hq, "Recording status: %s
    ", rstatus); - tcp_qprintf(tq, "
    ", + htsbuf_qprintf(hq, "", pvrr->pvrr_ref); switch(pvrstatus) { case HTSTV_PVR_STATUS_SCHEDULED: - tcp_qprintf(tq, ""); break; case HTSTV_PVR_STATUS_RECORDING: - tcp_qprintf(tq, ""); break; case HTSTV_PVR_STATUS_DONE: - tcp_qprintf(tq, ""); break; default: - tcp_qprintf(tq, ""); break; } - tcp_qprintf(tq, "
    "); - tcp_qprintf(tq, "%s", pvrr->pvrr_desc); + htsbuf_qprintf(hq, ""); + htsbuf_qprintf(hq, "%s", pvrr->pvrr_desc); - tcp_qprintf(tq, "
    New search
    "); - tcp_qprintf(tq, ""); + htsbuf_qprintf(hq, "
    New search
    "); + htsbuf_qprintf(hq, ""); http_output_html(hc, hr); return 0; } diff --git a/xbmsp.c b/xbmsp.c index e45da1d4..1cdb7501 100644 --- a/xbmsp.c +++ b/xbmsp.c @@ -55,7 +55,7 @@ xbmsp_output_file(void *opaque) 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; @@ -79,8 +79,8 @@ xbmsp_output_file(void *opaque) 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); @@ -88,10 +88,10 @@ xbmsp_output_file(void *opaque) 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; @@ -108,7 +108,7 @@ xbmsp_output_file(void *opaque) 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); } @@ -379,7 +379,7 @@ xbmsp_send_msg(xbmsp_t *xbmsp, uint8_t type, uint32_t msgid, uint8_t *payload, int payloadlen) { uint8_t buf[9]; - tcp_queue_t tq; + htsbuf_queue_t hq; int tlen = payloadlen + 5; @@ -393,16 +393,16 @@ xbmsp_send_msg(xbmsp_t *xbmsp, uint8_t type, uint32_t msgid, 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); }