From: Amos Jeffries Date: Thu, 3 Jul 2008 03:04:04 +0000 (+1200) Subject: Author: Henrik Nordstrom X-Git-Tag: SQUID_3_1_0_1~49^2~171 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e313f2b8cb37f3dfac17bedf35396e1e3a43488a;p=thirdparty%2Fsquid.git Author: Henrik Nordstrom Port from 2.6: Support for cachemgr sub-actions see. http://www.squid-cache.org/Versions/v2/2.6/changesets/10659.patch This brings the Squid-3 cachemgr.cgi up to parity and backwards compatibility with Squid 2.6 cachemgr.cgi --- diff --git a/tools/cachemgr.cc b/tools/cachemgr.cc index 29eb93a99b..c3becac532 100644 --- a/tools/cachemgr.cc +++ b/tools/cachemgr.cc @@ -579,6 +579,27 @@ munge_other_line(const char *buf, cachemgr_request * req) return html; } +static const char * +munge_action_line(const char *_buf, cachemgr_request * req) +{ + static char html[2 * 1024]; + char *buf = xstrdup(_buf); + char *x = buf; + const char *action, *description; + char *p; + + if ((p = strchr(x, '\n'))) + *p = '\0'; + action = xstrtok(&x, '\t'); + description = xstrtok(&x, '\t'); + if (!description) + description = action; + if (!action) + return ""; + snprintf(html, sizeof(html), " %s", menu_url(req, action), description); + return html; +} + static int read_reply(int s, cachemgr_request * req) { @@ -594,7 +615,7 @@ read_reply(int s, cachemgr_request * req) #endif /* interpretation states */ enum { - isStatusLine, isHeaders, isBodyStart, isBody, isForward, isEof, isForwardEof, isSuccess, isError + isStatusLine, isHeaders, isActions, isBodyStart, isBody, isForward, isEof, isForwardEof, isSuccess, isError } istate = isStatusLine; int parse_menu = 0; const char *action = req->action; @@ -688,6 +709,22 @@ read_reply(int s, cachemgr_request * req) printf("
\n");
             }
 
+            istate = isActions;
+            /* yes, fall through, we do not want to loose the first line */
+
+        case isActions:
+            if (strncmp(buf, "action:", 7) == 0) {
+                fputs(" ", stdout);
+                fputs(munge_action_line(buf + 7, req), stdout);
+                break;
+            }
+            if (parse_menu) {
+                printf("
    \n"); + } else { + printf("
    \n"); + printf("
    \n");
    +            }
    +
                 istate = isBody;
                 /* yes, fall through, we do not want to loose the first line */
     
    @@ -708,9 +745,7 @@ read_reply(int s, cachemgr_request * req)
                  * 401 to .cgi because web server filters out all auth info. Thus we
                  * disable authentication headers for now.
                  */
    -            if (!strncasecmp(buf, "WWW-Authenticate:", 17) || !strncasecmp(buf, "Proxy-Authenticate:", 19))
    -
    -                ;	/* skip */
    +            if (!strncasecmp(buf, "WWW-Authenticate:", 17) || !strncasecmp(buf, "Proxy-Authenticate:", 19));	/* skip */
                 else
                     fputs(buf, stdout);