From: Zdeněk Šustr Date: Thu, 2 Aug 2012 09:25:27 +0000 (+0000) Subject: Apply optional style headers to HTML output X-Git-Tag: glite-lb-server_R_2_4_3_1~6 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=eb11065bc2e58ff1d57b0317056894df44755ef2;p=jra1mw.git Apply optional style headers to HTML output --- diff --git a/org.glite.lb.server/src/bkserverd.c b/org.glite.lb.server/src/bkserverd.c index 956b847..bfa0191 100644 --- a/org.glite.lb.server/src/bkserverd.c +++ b/org.glite.lb.server/src/bkserverd.c @@ -600,7 +600,6 @@ int main(int argc, char *argv[]) } else { glite_common_log(LOG_CATEGORY_CONTROL, html_header_forced ? LOG_PRIORITY_ERROR : LOG_PRIORITY_INFO, "Cannot open HTML header file %s", html_header); } - ctx->html_header_file=html_header; } if (msg_conf) { @@ -1098,6 +1097,7 @@ int bk_handle_connection(int conn, struct timeval *timeout, void *data) ctx->rssTime = rss_time; if (policy_file) ctx->authz_policy_file = strdup(policy_file); + if (html_header) ctx->html_header_file = strdup(html_header); gettimeofday(&conn_start, 0); diff --git a/org.glite.lb.server/src/lb_html.c b/org.glite.lb.server/src/lb_html.c index fa3858f..1076192 100644 --- a/org.glite.lb.server/src/lb_html.c +++ b/org.glite.lb.server/src/lb_html.c @@ -42,6 +42,22 @@ limitations under the License. #define UNUSED_VAR #endif +char *get_html_header(edg_wll_Context ctx, int text) { + char *header = NULL; + size_t header_len = 0; + FILE *header_file; + + if (text) return NULL; + + if ((header_file = fopen(ctx->html_header_file, "r"))) { + getdelim( &header, &header_len, '\0', header_file); + fclose (header_file); + } + else header=strdup(""); + + return header; +} + int edg_wll_QueryToHTML(edg_wll_Context ctx UNUSED_VAR, edg_wll_Event *eventsOut UNUSED_VAR, char **message UNUSED_VAR) { /* not implemented yet */ @@ -64,7 +80,6 @@ int edg_wll_UserInfoToHTML(edg_wll_Context ctx UNUSED_VAR, edg_wlc_JobId *jobsOu char *pomA = NULL, *pomB, *pomC, *header = NULL; int i, total = 0, bufsize, written = 0, linlen, wassub = 0, lineoverhead; JobIdSorter *order; - FILE *header_file; while (jobsOut && jobsOut[total]) total++; @@ -85,8 +100,8 @@ int edg_wll_UserInfoToHTML(edg_wll_Context ctx UNUSED_VAR, edg_wlc_JobId *jobsOu else { qsort(order, total, sizeof(JobIdSorter), jobstat_cmp); - if (header_file = fopen(ctx->html_header_file, "r")) getdelim( &header, 0, '\0', header_file); - + header = get_html_header(ctx, text); + linlen = asprintf(&pomA, "\n\nUser Jobs\n\n%s\n\n\n" "

User Jobs

\nTotal of %d