From d96a70ba6c5ec0ef091631299286b20d7af40ca2 Mon Sep 17 00:00:00 2001 From: oes Date: Fri, 5 Apr 2002 15:50:53 +0000 Subject: [PATCH] added send-stylesheet CGI --- cgisimple.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++---- cgisimple.h | 12 ++++++++--- 2 files changed, 67 insertions(+), 7 deletions(-) diff --git a/cgisimple.c b/cgisimple.c index 701d3d81..54d4eec6 100644 --- a/cgisimple.c +++ b/cgisimple.c @@ -1,4 +1,4 @@ -const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.25 2002/04/03 22:28:03 gliptak Exp $"; +const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.26 2002/04/04 00:36:36 gliptak Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgisimple.c,v $ @@ -36,6 +36,9 @@ const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.25 2002/04/03 22:28:03 glipta * * Revisions : * $Log: cgisimple.c,v $ + * Revision 1.26 2002/04/04 00:36:36 gliptak + * always use pcre for matching + * * Revision 1.25 2002/04/03 22:28:03 gliptak * Removed references to gnu_regex * @@ -162,6 +165,7 @@ const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.25 2002/04/03 22:28:03 glipta #include "loadcfg.h" #include "parsers.h" #include "urlmatch.h" +#include "errlog.h" const char cgisimple_h_rcs[] = CGISIMPLE_H_VERSION; @@ -484,8 +488,8 @@ jb_err cgi_send_banner(struct client_state *csp, * *********************************************************************/ jb_err cgi_transparent_image(struct client_state *csp, - struct http_response *rsp, - const struct map *parameters) + struct http_response *rsp, + const struct map *parameters) { rsp->body = bindup(image_blank_data, image_blank_length); rsp->content_length = image_blank_length; @@ -507,6 +511,57 @@ jb_err cgi_transparent_image(struct client_state *csp, } +/********************************************************************* + * + * Function : cgi_send_stylesheet + * + * Description : CGI function that sends a css stylesheet found + * in the cgi-style.css template + * + * Parameters : + * 1 : csp = Current client state (buffers, headers, etc...) + * 2 : rsp = http_response data structure for output + * 3 : parameters = map of cgi parameters + * + * CGI Parameters : None + * + * Returns : JB_ERR_OK on success + * JB_ERR_MEMORY on out-of-memory error. + * + *********************************************************************/ +jb_err cgi_send_stylesheet(struct client_state *csp, + struct http_response *rsp, + const struct map *parameters) +{ + jb_err err; + + assert(csp); + assert(rsp); + + err = template_load(csp, &rsp->body, "cgi-style.css"); + + if (err == JB_ERR_FILE) + { + /* + * No way to tell user; send empty stylesheet + */ + log_error(LOG_LEVEL_ERROR, "Could not find cgi-style.css template"); + } + else if (err) + { + return err; /* JB_ERR_MEMORY */ + } + + if (enlist(rsp->headers, "Content-Type: text/css")) + { + return JB_ERR_MEMORY; + } + + return JB_ERR_OK; + +} + + /********************************************************************* * * Function : cgi_show_version @@ -655,7 +710,6 @@ jb_err cgi_show_status(struct client_state *csp, while ((s != NULL) && fgets(buf, sizeof(buf), fp)) { string_join (&s, html_encode(buf)); - string_append(&s, "
"); } fclose(fp); diff --git a/cgisimple.h b/cgisimple.h index 753afcc2..88501d7f 100644 --- a/cgisimple.h +++ b/cgisimple.h @@ -1,6 +1,6 @@ #ifndef CGISIMPLE_H_INCLUDED #define CGISIMPLE_H_INCLUDED -#define CGISIMPLE_H_VERSION "$Id: cgisimple.h,v 1.9 2002/03/24 13:25:43 swa Exp $" +#define CGISIMPLE_H_VERSION "$Id: cgisimple.h,v 1.10 2002/03/26 22:29:54 swa Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgisimple.h,v $ @@ -38,6 +38,9 @@ * * Revisions : * $Log: cgisimple.h,v $ + * Revision 1.10 2002/03/26 22:29:54 swa + * we have a new homepage! + * * Revision 1.9 2002/03/24 13:25:43 swa * name change related issues * @@ -117,8 +120,11 @@ extern jb_err cgi_show_request (struct client_state *csp, struct http_response *rsp, const struct map *parameters); extern jb_err cgi_transparent_image (struct client_state *csp, - struct http_response *rsp, - const struct map *parameters); + struct http_response *rsp, + const struct map *parameters); +extern jb_err cgi_send_stylesheet(struct client_state *csp, + struct http_response *rsp, + const struct map *parameters); #ifdef FEATURE_GRACEFUL_TERMINATION extern jb_err cgi_die (struct client_state *csp, -- 2.39.2