From 4d5562a93fbe978ed96fa679ed32f8936682824a Mon Sep 17 00:00:00 2001 From: jongfoster Date: Sun, 16 Sep 2001 11:00:10 +0000 Subject: [PATCH] New function alloc_http_response, for symmetry with free_http_response --- cgi.c | 27 ++++++++++++++++++++++++--- cgi.h | 9 +++++++-- filters.c | 13 +++++++++---- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/cgi.c b/cgi.c index a7554bdc..81ee4b3b 100644 --- a/cgi.c +++ b/cgi.c @@ -1,4 +1,4 @@ -const char cgi_rcs[] = "$Id: cgi.c,v 1.20 2001/09/13 23:40:36 jongfoster Exp $"; +const char cgi_rcs[] = "$Id: cgi.c,v 1.21 2001/09/13 23:53:03 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgi.c,v $ @@ -36,6 +36,10 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.20 2001/09/13 23:40:36 jongfoster Exp $"; * * Revisions : * $Log: cgi.c,v $ + * Revision 1.21 2001/09/13 23:53:03 jongfoster + * Support for both static and dynamically generated CGI pages. + * Correctly setting Last-Modified: and Expires: HTTP headers. + * * Revision 1.20 2001/09/13 23:40:36 jongfoster * (Cosmetic only) Indentation correction * @@ -285,7 +289,7 @@ struct http_response *dispatch_cgi(struct client_state *csp) */ /* Get mem for response or fail*/ - if (NULL == ( rsp = zalloc(sizeof(*rsp)))) + if (NULL == (rsp = alloc_http_response())) { return NULL; } @@ -818,7 +822,7 @@ struct http_response *error_response(struct client_state *csp, const char *templ struct http_response *rsp; struct map * exports = default_exports(csp, NULL); - if (NULL == ( rsp = (struct http_response *)zalloc(sizeof(*rsp)))) + if (NULL == (rsp = alloc_http_response())) { return NULL; } @@ -998,6 +1002,23 @@ struct http_response *finish_http_response(struct http_response *rsp) } +/********************************************************************* + * + * Function : alloc_http_response + * + * Description : Allocates a new http_response structure. + * + * Parameters : N/A + * + * Returns : pointer to a new http_response, or NULL. + * + *********************************************************************/ +struct http_response * alloc_http_response(void) +{ + return (struct http_response *) zalloc(sizeof(struct http_response)); +} + + /********************************************************************* * * Function : free_http_response diff --git a/cgi.h b/cgi.h index 2217b065..56016bbb 100644 --- a/cgi.h +++ b/cgi.h @@ -1,6 +1,6 @@ #ifndef CGI_H_INCLUDED #define CGI_H_INCLUDED -#define CGI_H_VERSION "$Id: cgi.h,v 1.11 2001/08/05 16:06:20 jongfoster Exp $" +#define CGI_H_VERSION "$Id: cgi.h,v 1.12 2001/09/13 23:31:25 jongfoster Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgi.h,v $ @@ -38,6 +38,9 @@ * * Revisions : * $Log: cgi.h,v $ + * Revision 1.12 2001/09/13 23:31:25 jongfoster + * Moving image data to cgi.c rather than cgi.h. + * * Revision 1.11 2001/08/05 16:06:20 jongfoster * Modifiying "struct map" so that there are now separate header and * "map_entry" structures. This means that functions which modify a @@ -116,9 +119,11 @@ extern struct http_response *error_response(struct client_state *csp, const char /* * CGI support functions */ -extern struct http_response *finish_http_response(struct http_response *rsp); +extern struct http_response * alloc_http_response(void); extern void free_http_response(struct http_response *rsp); +extern struct http_response *finish_http_response(struct http_response *rsp); + extern struct map * default_exports(const struct client_state *csp, const char *caller); extern void map_block_killer(struct map *map, const char *name); extern void map_conditional(struct map *exports, const char *name, int choose_first); diff --git a/filters.c b/filters.c index 4851dff2..42446193 100644 --- a/filters.c +++ b/filters.c @@ -1,4 +1,4 @@ -const char filters_rcs[] = "$Id: filters.c,v 1.28 2001/09/10 10:18:51 oes Exp $"; +const char filters_rcs[] = "$Id: filters.c,v 1.29 2001/09/13 23:32:40 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/filters.c,v $ @@ -38,6 +38,11 @@ const char filters_rcs[] = "$Id: filters.c,v 1.28 2001/09/10 10:18:51 oes Exp $" * * Revisions : * $Log: filters.c,v $ + * Revision 1.29 2001/09/13 23:32:40 jongfoster + * Moving image data to cgi.c rather than cgi.h + * Fixing a GPF under Win32 (and any other OS that protects global + * constants from being written to). + * * Revision 1.28 2001/09/10 10:18:51 oes * Silenced compiler warnings * @@ -472,7 +477,7 @@ struct http_response *block_url(struct client_state *csp) /* * Else, prepare a response */ - if (NULL == ( rsp = (struct http_response *)zalloc(sizeof(*rsp)))) + if (NULL == (rsp = alloc_http_response())) { return NULL; } @@ -588,7 +593,7 @@ struct http_response *trust_url(struct client_state *csp) /* * Else, prepare a response: */ - if (NULL == ( rsp = (struct http_response *)zalloc(sizeof(*rsp)))) + if (NULL == (rsp = alloc_http_response())) { return NULL; } @@ -702,7 +707,7 @@ struct http_response *redirect_url(struct client_state *csp) { log_error(LOG_LEVEL_REDIRECTS, "redirecting to: %s", q); - if (NULL == ( rsp = zalloc(sizeof(*rsp)))) + if (NULL == (rsp = alloc_http_response())) { return NULL; } -- 2.39.2