From e1a5911ec4ffee093da8352b1b6973d40b322f77 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Mon, 26 May 2008 17:30:59 +0000 Subject: [PATCH] Provide an OpenSearch Description to access the show-url-info page through "search engine plugins". --- cgi.c | 11 +++++++-- cgisimple.c | 48 +++++++++++++++++++++++++++++++++++++- cgisimple.h | 8 ++++++- templates/show-url-info | 6 +++++ templates/url-info-osd.xml | 14 +++++++++++ 5 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 templates/url-info-osd.xml diff --git a/cgi.c b/cgi.c index 8a0ce49e..cc8ef2cc 100644 --- a/cgi.c +++ b/cgi.c @@ -1,4 +1,4 @@ -const char cgi_rcs[] = "$Id: cgi.c,v 1.106 2008/05/21 15:24:38 fabiankeil Exp $"; +const char cgi_rcs[] = "$Id: cgi.c,v 1.107 2008/05/26 16:23:19 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgi.c,v $ @@ -11,7 +11,7 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.106 2008/05/21 15:24:38 fabiankeil Exp $" * Functions declared include: * * - * Copyright : Written by and Copyright (C) 2001-2004, 2006-2007 + * Copyright : Written by and Copyright (C) 2001-2004, 2006-2008 * the SourceForge Privoxy team. http://www.privoxy.org/ * * Based on the Internet Junkbuster originally written @@ -38,6 +38,10 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.106 2008/05/21 15:24:38 fabiankeil Exp $" * * Revisions : * $Log: cgi.c,v $ + * Revision 1.107 2008/05/26 16:23:19 fabiankeil + * - Fix spelling in template-not-found message. + * - Declare referrer_is_safe()'s alternative_prefix[] static. + * * Revision 1.106 2008/05/21 15:24:38 fabiankeil * Mark csp as immutable for a bunch of functions. * @@ -768,6 +772,9 @@ static const struct cgi_dispatcher cgi_dispatchers[] = { { "t", cgi_transparent_image, NULL, TRUE /* Send a transparent image (short name) */ }, + { "url-info-osd.xml", + cgi_send_url_info_osd, + NULL, TRUE /* Send templates/url-info-osd.xml */ }, { "user-manual", cgi_send_user_manual, NULL, TRUE /* Send user-manual */ }, diff --git a/cgisimple.c b/cgisimple.c index a27598b5..9448bf3b 100644 --- a/cgisimple.c +++ b/cgisimple.c @@ -1,4 +1,4 @@ -const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.83 2008/05/12 14:51:30 fabiankeil Exp $"; +const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.84 2008/05/26 16:16:55 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgisimple.c,v $ @@ -36,6 +36,9 @@ const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.83 2008/05/12 14:51:30 fabian * * Revisions : * $Log: cgisimple.c,v $ + * Revision 1.84 2008/05/26 16:16:55 fabiankeil + * Spell error correctly. + * * Revision 1.83 2008/05/12 14:51:30 fabiankeil * Don't complain about an invalid URL if show-url-info is requested * without parameters. Regression introduced in 1.81 by yours truly. @@ -978,6 +981,49 @@ jb_err cgi_send_stylesheet(struct client_state *csp, return JB_ERR_OK; } + + +/********************************************************************* + * + * Function : cgi_send_url_info_osd + * + * Description : CGI function that sends the OpenSearch Description + * template for the show-url-info page. It allows to + * access the page through "search engine plugins". + * + * 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_url_info_osd(struct client_state *csp, + struct http_response *rsp, + const struct map *parameters) +{ + jb_err err = JB_ERR_MEMORY; + struct map *exports = default_exports(csp, NULL); + + if (NULL != exports) + { + err = template_fill_for_cgi(csp, "url-info-osd.xml", exports, rsp); + if (JB_ERR_OK == err) + { + err = enlist(rsp->headers, + "Content-Type: application/opensearchdescription+xml"); + } + } + + return err; + +} + + /********************************************************************* * * Function : cgi_send_user_manual diff --git a/cgisimple.h b/cgisimple.h index 87788944..9ca0565c 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.14 2006/09/06 18:45:03 fabiankeil Exp $" +#define CGISIMPLE_H_VERSION "$Id: cgisimple.h,v 1.15 2007/01/23 15:51:17 fabiankeil Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgisimple.h,v $ @@ -38,6 +38,9 @@ * * Revisions : * $Log: cgisimple.h,v $ + * Revision 1.15 2007/01/23 15:51:17 fabiankeil + * Add favicon delivery functions. + * * Revision 1.14 2006/09/06 18:45:03 fabiankeil * Incorporate modified version of Roland Rosenfeld's patch to * optionally access the user-manual via Privoxy. Closes patch 679075. @@ -147,6 +150,9 @@ extern jb_err cgi_send_default_favicon (struct client_state *csp, extern jb_err cgi_send_stylesheet(struct client_state *csp, struct http_response *rsp, const struct map *parameters); +extern jb_err cgi_send_url_info_osd(struct client_state *csp, + struct http_response *rsp, + const struct map *parameters); extern jb_err cgi_send_user_manual(struct client_state *csp, struct http_response *rsp, const struct map *parameters); diff --git a/templates/show-url-info b/templates/show-url-info index f57b066d..4c2b9e1e 100644 --- a/templates/show-url-info +++ b/templates/show-url-info @@ -27,6 +27,11 @@ # # Revisions : # $Log: show-url-info,v $ +# Revision 1.26 2008/05/05 10:03:06 fabiankeil +# If the provided URL isn't valid, don't show the +# cgi-editor-is-disabled and filters-might-be-ineffective +# sections. +# # Revision 1.25 2008/04/26 10:34:18 fabiankeil # If zlib support is unavailable and there are content filters active # but the prevent-compression action is disabled, include a warning @@ -159,6 +164,7 @@ + diff --git a/templates/url-info-osd.xml b/templates/url-info-osd.xml new file mode 100644 index 00000000..3fbaaf12 --- /dev/null +++ b/templates/url-info-osd.xml @@ -0,0 +1,14 @@ + + + Privoxy URL Info + + Enter a URL to see which Privoxy actions apply. + Only works while the browser is configured to use Privoxy. + + ISO-8859-1 + ISO-8859-1 + Privoxy Team + ijbswa-developers@lists.sourceforge.net + @default-cgi@favicon.ico + + -- 2.39.2