From: jongfoster Date: Wed, 1 Aug 2001 00:19:03 +0000 (+0000) Subject: New function: map_conditional() for an if-then-else syntax. X-Git-Tag: v_2_9_9~168 X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=commitdiff_plain;h=7679acc0d466f9ed8e0007d5c472b5e2e527c255 New function: map_conditional() for an if-then-else syntax. Changing to use new version of show_defines() --- diff --git a/cgi.c b/cgi.c index d2d6d933..7d3fb087 100644 --- a/cgi.c +++ b/cgi.c @@ -1,4 +1,4 @@ -const char cgi_rcs[] = "$Id: cgi.c,v 1.12 2001/07/29 18:47:05 jongfoster Exp $"; +const char cgi_rcs[] = "$Id: cgi.c,v 1.13 2001/07/30 22:08:36 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgi.c,v $ @@ -36,6 +36,12 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.12 2001/07/29 18:47:05 jongfoster Exp $"; * * Revisions : * $Log: cgi.c,v $ + * Revision 1.13 2001/07/30 22:08:36 jongfoster + * Tidying up #defines: + * - All feature #defines are now of the form FEATURE_xxx + * - Permanently turned off WIN_GUI_EDIT + * - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS + * * Revision 1.12 2001/07/29 18:47:05 jongfoster * Adding missing #include "loadcfg.h" * @@ -485,8 +491,7 @@ int cgi_show_status(struct client_state *csp, struct http_response *rsp, exports = map(exports, "options", 1, csp->config->proxy_args, 1); s = show_rcs(); exports = map(exports, "sourceversions", 1, s, 0); - s = show_defines(); - exports = map(exports, "defines", 1, s, 0); + exports = show_defines(exports); #ifdef FEATURE_STATISTICS exports = add_stats(exports); @@ -494,8 +499,6 @@ int cgi_show_status(struct client_state *csp, struct http_response *rsp, exports = map_block_killer(exports, "statistics"); #endif /* ndef FEATURE_STATISTICS */ - exports = map_block_killer(exports, "no-split-args"); - if (csp->actions_list) { exports = map(exports, "actions-filename", 1, csp->actions_list->filename, 1); @@ -1009,6 +1012,48 @@ struct map *map_block_killer(struct map *exports, char *name) } +/********************************************************************* + * + * Function : map_conditional + * + * Description : Convenience function. + * Adds an "if-then-else" for the conditional HTML-template + * block , i.e. a substitution of the form: + * @if--then@ + * True text + * @else-not-@ + * False text + * @endif-@ + * + * The control structure and one of the alternatives + * will be hidden. + * + * Parameters : + * 1 : exports = map to extend + * 2 : name = name of conditional block + * 3 : choose_first = nonzero for first, zero for second. + * + * Returns : extended map + * + *********************************************************************/ +struct map *map_conditional(struct map *exports, char *name, int choose_first) +{ + char buf[1000]; /* Will do, since the names are hardwired */ + + snprintf(buf, 1000, (choose_first + ? "else-not-%s@.*@endif-%s" + : "if-%s-then@.*@else-not-%s"), + name, name); + exports = map(exports, buf, 1, "", 1); + + snprintf(buf, 1000, (choose_first ? "if-%s-then" : "endif-%s"), name); + exports = map(exports, buf, 1, "", 1); + + return(exports); + +} + + /********************************************************************* * * Function : make_menu