-const char cgisimple_rcs[] = "$Id: cgi.c,v 1.26 2001/09/16 15:47:37 jongfoster Exp $";
+const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.5 2001/10/07 15:30:41 oes Exp $";
/*********************************************************************
*
- * File : $Source: /cvsroot/ijbswa/current/cgi.c,v $
+ * File : $Source: /cvsroot/ijbswa/current/cgisimple.c,v $
*
* Purpose : Simple CGIs to get information about JunkBuster's
* status.
* Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Revisions :
- * $Log: cgi.c,v $
+ * $Log: cgisimple.c,v $
+ * Revision 1.5 2001/10/07 15:30:41 oes
+ * Removed FEATURE_DENY_GZIP
+ *
+ * Revision 1.4 2001/10/02 15:31:12 oes
+ * Introduced show-request cgi
+ *
+ * Revision 1.3 2001/09/22 16:34:44 jongfoster
+ * Removing unneeded #includes
+ *
+ * Revision 1.2 2001/09/19 18:01:11 oes
+ * Fixed comments; cosmetics
+ *
+ * Revision 1.1 2001/09/16 17:08:54 jongfoster
+ * Moving simple CGI functions from cgi.c to new file cgisimple.c
+ *
*
**********************************************************************/
\f
#include "cgisimple.h"
#include "list.h"
#include "encode.h"
-#include "ssplit.h"
#include "jcc.h"
#include "filters.h"
#include "actions.h"
-#include "errlog.h"
#include "miscutil.h"
#include "loadcfg.h"
+#include "parsers.h"
const char cgisimple_h_rcs[] = CGISIMPLE_H_VERSION;
{
char *p;
char *tmp = NULL;
- struct map * exports = default_exports(csp, "");
+ struct map *exports = default_exports(csp, "");
/* If there were other parameters, export a dump as "cgi-parameters" */
if(parameters)
}
+
+
+/*********************************************************************
+ *
+ * Function : cgi_error_404
+ *
+ * Description : CGI function that is called if an unknow action was
+ * given.
+ *
+ * Parameters :
+ * 1 : csp = Current client state (buffers, headers, etc...)
+ * 2 : rsp = http_response data structure for output
+ * 3 : parameters = map of cgi parameters
+ *
+ * Returns : 0
+ *
+ *********************************************************************/
+int cgi_error_404(struct client_state *csp,
+ struct http_response *rsp,
+ struct map *parameters)
+{
+ struct map *exports = default_exports(csp, NULL);
+
+ rsp->status = strdup("404 JunkBuster configuration page not found");
+ rsp->body = template_load(csp, "cgi-error-404");
+ template_fill(&rsp->body, exports);
+ free_map(exports);
+ return 0;
+}
+
+
+/*********************************************************************
+ *
+ * Function : cgi_show_request
+ *
+ * Description : Show the client's request and what sed() would have
+ * made of it.
+ *
+ * Parameters :
+ * 1 : csp = Current client state (buffers, headers, etc...)
+ * 2 : rsp = http_response data structure for output
+ * 3 : parameters = map of cgi parameters
+ *
+ * Returns : 0
+ *
+ *********************************************************************/
+int cgi_show_request(struct client_state *csp, struct http_response *rsp,
+ struct map *parameters)
+{
+ char *p;
+ struct map *exports = default_exports(csp, "show-request");
+
+ /*
+ * Repair the damage done to the IOB by get_header()
+ */
+ for (p = csp->iob->buf; p < csp->iob->eod; p++)
+ {
+ if (*p == '\0') *p = '\n';
+ }
+
+ /*
+ * Export the original client's request and the one we would
+ * be sending to the server if this wasn't a CGI call
+ */
+ map(exports, "client-request", 1, csp->iob->buf, 1);
+ map(exports, "processed-request", 1, sed(client_patterns, add_client_headers, csp), 0);
+
+ rsp->body = template_load(csp, "show-request");
+ template_fill(&rsp->body, exports);
+ free_map(exports);
+ return(0);
+
+}
+
+
/*********************************************************************
*
* Function : cgi_send_banner
* 2 : rsp = http_response data structure for output
* 3 : parameters = map of cgi parameters
*
- * CGI Parameters :
- * type : Selects the type of banner between "trans" and "jb".
- * Defaults to "jb" if absent or != "trans".
+ * CGI Parameters : none
*
* Returns : 0
*
rsp->body = template_load(csp, "show-version");
template_fill(&rsp->body, exports);
free_map(exports);
+
return(0);
}
* 2 : rsp = http_response data structure for output
* 3 : parameters = map of cgi parameters
*
- * CGI Parameters :
- * type : Selects the type of banner between "trans" and "jb".
- * Defaults to "jb" if absent or != "trans".
+ * CGI Parameters : none
*
* Returns : 0
*
enlist_unique_header(rsp->headers, "Expires", buf);
return 0;
+
}
map_conditional(exports, "FEATURE_COOKIE_JAR", 0);
#endif /* ndef FEATURE_COOKIE_JAR */
-#ifdef FEATURE_DENY_GZIP
- map_conditional(exports, "FEATURE_DENY_GZIP", 1);
-#else /* ifndef FEATURE_DENY_GZIP */
- map_conditional(exports, "FEATURE_DENY_GZIP", 0);
-#endif /* ndef FEATURE_DENY_GZIP */
-
#ifdef FEATURE_FAST_REDIRECTS
map_conditional(exports, "FEATURE_FAST_REDIRECTS", 1);
#else /* ifndef FEATURE_FAST_REDIRECTS */
#endif /* ndef STATIC_PCRS */
map(exports, "FORCE_PREFIX", 1, FORCE_PREFIX, 1);
+
}
#undef SHOW_RCS
return(b);
+
}