CGI support has numerous security issues.  In general, it is not
safe to take some command line program, add a shim to translate
URL query parameters into command line options, and use the result
safely.  In particular, the program cannot be configured through
URL query parameters for this to be safe, it has to be sever-side
configuration that is independent from the request.  In the
source-highlight case, there are numerous options to control
input files, output files, and commands, so configuration through
URL query parameters is insecure.

I've been advised to include this statement: Found by AISLE in
partnership with Red Hat.  (However the reports were not very good.
They identified many alleged problems with the CGI implementation, but
never pointed out in clear terms that this can never be made to work
securely within the current framework.)  This paragraph obviously does
not need preserving in the Git history.

Thanks,
Florian

(resend due to suspected mailing list issue)

diff --git a/NEWS b/NEWS
index 111485a..c3ac616 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,8 @@ Changes after 3.1.9
 
    * Now uses the std::shared_ptr rather than the Boost equivalent
 
+   * CGI support was removed due to security concerns.
+
 Version 3.1.9
 
    * changed esc.style to work better with dark theme terminals
diff --git a/doc/index.html b/doc/index.html
index 44a2ca6..eab76f0 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -21,8 +21,7 @@ thus it can be easily extended (without recompiling
 the sources) for handling new output formats.
 The syntax for these specifications is quite easy (take a look at the
 manual).</p>
-<p>Source-highlight is a command line program, and it can also be
-used as a <a 
href="source-highlight.html#Using-source_002dhighlight-as-a-CGI">CGI</a>.</p>
+<p>Source-highlight is a command line program.</p>
 <p>Notice that source-highlight can also be used as a formatter
 (i.e.,
 without highlighting): you can, for instance, format a txt file in HTML
diff --git a/doc/source-highlight.texi b/doc/source-highlight.texi
index cc4ae5c..559c597 100644
--- a/doc/source-highlight.texi
+++ b/doc/source-highlight.texi
@@ -403,8 +403,7 @@ of source code fragments and whole files via 
source-highlight.
 @cindex Wiki
 @cindex Php
 Pascal Bleser created a PHP extension that uses the GNU source-highlight
-library directly from PHP, instead of relying on spawning a process or
-using the source-highlight CGI.
+library directly from PHP.
 
 @uref{http://code.google.com/p/php-source-highlight/}
 
@@ -538,7 +537,6 @@ together with Source-highlight in order to facilitate the 
migration
 * Tips on installing Boost Regex library::  
 * Patching from a previous version::  
 * Using source-highlight with less::  
-* Using source-highlight as a CGI::  
 * Building .rpm::               
 @end menu
 
@@ -922,7 +920,7 @@ gunzip -cd ../source-highlight-1.3-1.3.1.patch.gz | patch 
-p1
 and restart the compilation process (if you had already run configure a
 simple make should do).
 
-@node Using source-highlight with less, Using source-highlight as a CGI, 
Patching from a previous version, Installation
+@node Using source-highlight with less, Building .rpm, Patching from a 
previous version, Installation
 @section Using source-highlight with less
 
 @cindex src-hilite-lesspipe.sh
@@ -946,25 +944,7 @@ your terminal can handle, and in case, uses the 256 
variant.  The
 script is called @file{source-highlight-esc.sh} and it will be
 installed together with the other binaries.
 
-@node Using source-highlight as a CGI, Building .rpm, Using source-highlight 
with less, Installation
-@section Using source-highlight as a CGI
-
-@cindex CGI
-CGI support was enabled thanks to Robert Wetzel; I haven't tested it
-personally.  If you want to use source-highlight as a CGI program, you
-have to use the executable source-highlight-cgi.  You can build such
-executable by issuing
-
-@example
-make source-highlight-cgi
-@end example
-
-@noindent
-in the @file{src} directory.
-
-
-
-@node Building .rpm,  , Using source-highlight as a CGI, Installation
+@node Building .rpm,  , Using source-highlight with less, Installation
 @section Building .rpm
 @cindex rpm
 
diff --git a/lib/srchilite/stylecssscanner.cc b/lib/srchilite/stylecssscanner.cc
index 1f71d68..a4e66d0 100644
--- a/lib/srchilite/stylecssscanner.cc
+++ b/lib/srchilite/stylecssscanner.cc
@@ -918,8 +918,8 @@ int yy_flex_debug = 0;
 #define YY_MORE_ADJ 0
 #define YY_RESTORE_YY_MORE_OFFSET
 char *yytext;
-#line 1 "../../../lib/srchilite/stylecssscanner.ll"
-#line 2 "../../../lib/srchilite/stylecssscanner.ll"
+#line 1 "stylecssscanner.ll"
+#line 2 "stylecssscanner.ll"
 /*
  * Copyright (C) 1999-2007 Lorenzo Bettini, http://www.lorenzobettini.it
  *
@@ -1199,7 +1199,7 @@ YY_DECL
                }
 
        {
-#line 69 "../../../lib/srchilite/stylecssscanner.ll"
+#line 69 "stylecssscanner.ll"
 
 
 #line 1204 "<stdout>"
@@ -1261,49 +1261,49 @@ do_action:      /* This label is used only to access 
EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 71 "../../../lib/srchilite/stylecssscanner.ll"
+#line 71 "stylecssscanner.ll"
 {}
        YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 73 "../../../lib/srchilite/stylecssscanner.ll"
+#line 73 "stylecssscanner.ll"
 {}
        YY_BREAK
 case 3:
 YY_RULE_SETUP
-#line 75 "../../../lib/srchilite/stylecssscanner.ll"
+#line 75 "stylecssscanner.ll"
 { BEGIN(MULTI_COMMENT_STATE); }
        YY_BREAK
 case 4:
 YY_RULE_SETUP
-#line 76 "../../../lib/srchilite/stylecssscanner.ll"
+#line 76 "stylecssscanner.ll"
 {}
        YY_BREAK
 case 5:
 /* rule 5 can match eol */
 YY_RULE_SETUP
-#line 77 "../../../lib/srchilite/stylecssscanner.ll"
+#line 77 "stylecssscanner.ll"
 { ++line;  BEGIN(INITIAL); }
        YY_BREAK
 case 6:
 YY_RULE_SETUP
-#line 80 "../../../lib/srchilite/stylecssscanner.ll"
+#line 80 "stylecssscanner.ll"
 { return ',' ; }
        YY_BREAK
 case 7:
 YY_RULE_SETUP
-#line 81 "../../../lib/srchilite/stylecssscanner.ll"
+#line 81 "stylecssscanner.ll"
 { stylecsssc_lval.string = new std::string(yytext) ; return KEY ; }
        YY_BREAK
 case 8:
 /* rule 8 can match eol */
 YY_RULE_SETUP
-#line 83 "../../../lib/srchilite/stylecssscanner.ll"
+#line 83 "stylecssscanner.ll"
 { ++line ; }
        YY_BREAK
 case 9:
 YY_RULE_SETUP
-#line 85 "../../../lib/srchilite/stylecssscanner.ll"
+#line 85 "stylecssscanner.ll"
 {
   BEGIN(CSS_SELECTOR) ;
   DEB("CSS SELECTOR");
@@ -1311,7 +1311,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 10:
 YY_RULE_SETUP
-#line 89 "../../../lib/srchilite/stylecssscanner.ll"
+#line 89 "stylecssscanner.ll"
 {
   BEGIN(CSS_SELECTOR) ;
   DEB("BODY CSS SELECTOR");
@@ -1321,7 +1321,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 11:
 YY_RULE_SETUP
-#line 96 "../../../lib/srchilite/stylecssscanner.ll"
+#line 96 "stylecssscanner.ll"
 {
   // in case of comma separated selectors
   DEB("CSS SELECTOR");
@@ -1329,7 +1329,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 12:
 YY_RULE_SETUP
-#line 100 "../../../lib/srchilite/stylecssscanner.ll"
+#line 100 "stylecssscanner.ll"
 {
   BEGIN(CSS_PROPERTIES);
   DEB("CSS PROPERTIES");
@@ -1337,7 +1337,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 13:
 YY_RULE_SETUP
-#line 104 "../../../lib/srchilite/stylecssscanner.ll"
+#line 104 "stylecssscanner.ll"
 {
   BEGIN(CSS_COLOR);
   DEB("CSS COLOR");
@@ -1345,7 +1345,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 14:
 YY_RULE_SETUP
-#line 108 "../../../lib/srchilite/stylecssscanner.ll"
+#line 108 "stylecssscanner.ll"
 {
   BEGIN(CSS_PROPERTIES);
   stylecsssc_lval.string = new std::string(yytext) ;
@@ -1355,7 +1355,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 15:
 YY_RULE_SETUP
-#line 114 "../../../lib/srchilite/stylecssscanner.ll"
+#line 114 "stylecssscanner.ll"
 {
   BEGIN(CSS_PROPERTIES);
   DEB2("CSS COLOR", yytext);
@@ -1369,7 +1369,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 16:
 YY_RULE_SETUP
-#line 124 "../../../lib/srchilite/stylecssscanner.ll"
+#line 124 "stylecssscanner.ll"
 {
   BEGIN(CSS_BG_COLOR);
   DEB("CSS BACKGROUND COLOR");
@@ -1377,7 +1377,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 17:
 YY_RULE_SETUP
-#line 128 "../../../lib/srchilite/stylecssscanner.ll"
+#line 128 "stylecssscanner.ll"
 {
   BEGIN(CSS_PROPERTIES);
   stylecsssc_lval.string = new std::string(yytext) ;
@@ -1387,7 +1387,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 18:
 YY_RULE_SETUP
-#line 134 "../../../lib/srchilite/stylecssscanner.ll"
+#line 134 "stylecssscanner.ll"
 {
   BEGIN(CSS_PROPERTIES);
   DEB2("CSS BG COLOR", yytext);
@@ -1401,7 +1401,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 19:
 YY_RULE_SETUP
-#line 144 "../../../lib/srchilite/stylecssscanner.ll"
+#line 144 "stylecssscanner.ll"
 {
   BEGIN(CSS_FONT_WEIGHT);
   DEB("CSS FONT WEIGHT");
@@ -1409,7 +1409,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 20:
 YY_RULE_SETUP
-#line 148 "../../../lib/srchilite/stylecssscanner.ll"
+#line 148 "stylecssscanner.ll"
 {
   BEGIN(CSS_PROPERTIES);
   if (strcmp(yytext, "bold") == 0) {
@@ -1422,7 +1422,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 21:
 YY_RULE_SETUP
-#line 157 "../../../lib/srchilite/stylecssscanner.ll"
+#line 157 "stylecssscanner.ll"
 {
   BEGIN(CSS_FONT_STYLE);
   DEB("CSS FONT STYLE");
@@ -1430,7 +1430,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 22:
 YY_RULE_SETUP
-#line 161 "../../../lib/srchilite/stylecssscanner.ll"
+#line 161 "stylecssscanner.ll"
 {
   BEGIN(CSS_PROPERTIES);
   if (strcmp(yytext, "italic") == 0) {
@@ -1443,7 +1443,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 23:
 YY_RULE_SETUP
-#line 170 "../../../lib/srchilite/stylecssscanner.ll"
+#line 170 "stylecssscanner.ll"
 {
   BEGIN(CSS_FONT_FAMILY);
   DEB("CSS FONT FAMILY");
@@ -1451,7 +1451,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 24:
 YY_RULE_SETUP
-#line 174 "../../../lib/srchilite/stylecssscanner.ll"
+#line 174 "stylecssscanner.ll"
 {
   BEGIN(CSS_PROPERTIES);
   if (strcmp(yytext, "monospace") == 0) {
@@ -1464,7 +1464,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 25:
 YY_RULE_SETUP
-#line 183 "../../../lib/srchilite/stylecssscanner.ll"
+#line 183 "stylecssscanner.ll"
 {
   BEGIN(CSS_TEXT_DECORATION);
   DEB("CSS TEXT DECORATION");
@@ -1472,7 +1472,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 26:
 YY_RULE_SETUP
-#line 187 "../../../lib/srchilite/stylecssscanner.ll"
+#line 187 "stylecssscanner.ll"
 {
   BEGIN(CSS_PROPERTIES);
   if (strcmp(yytext, "underline") == 0) {
@@ -1485,7 +1485,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 27:
 YY_RULE_SETUP
-#line 196 "../../../lib/srchilite/stylecssscanner.ll"
+#line 196 "stylecssscanner.ll"
 {
   BEGIN(INITIAL);
   DEB("CSS END PROPERTIES");
@@ -1498,7 +1498,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 28:
 YY_RULE_SETUP
-#line 205 "../../../lib/srchilite/stylecssscanner.ll"
+#line 205 "stylecssscanner.ll"
 {
   /* discard other characters */
   DEB2("CSS discarding", yytext);
@@ -1506,7 +1506,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 29:
 YY_RULE_SETUP
-#line 209 "../../../lib/srchilite/stylecssscanner.ll"
+#line 209 "stylecssscanner.ll"
 {
   /* discard other properties */
   DEB2("CSS PROPERTIES discarding", yytext);
@@ -1514,12 +1514,12 @@ YY_RULE_SETUP
        YY_BREAK
 case 30:
 YY_RULE_SETUP
-#line 214 "../../../lib/srchilite/stylecssscanner.ll"
+#line 214 "stylecssscanner.ll"
 { return yytext[0] ; }
        YY_BREAK
 case 31:
 YY_RULE_SETUP
-#line 216 "../../../lib/srchilite/stylecssscanner.ll"
+#line 216 "stylecssscanner.ll"
 ECHO;
        YY_BREAK
 #line 1524 "<stdout>"
@@ -2538,7 +2538,7 @@ void yyfree (void * ptr )
 
 #define YYTABLES_NAME "yytables"
 
-#line 216 "../../../lib/srchilite/stylecssscanner.ll"
+#line 216 "stylecssscanner.ll"
 
 
 
diff --git a/sourcehighlight.kdevelop b/sourcehighlight.kdevelop
index c2ba108..eff6aa8 100644
--- a/sourcehighlight.kdevelop
+++ b/sourcehighlight.kdevelop
@@ -30,7 +30,6 @@
       <envvars/>
       <runarguments>
         <source-highlight/>
-        <source-highlight-cgi/>
         <test_langdefparser/>
       </runarguments>
     </run>
diff --git a/src/Makefile.am b/src/Makefile.am
index b4da761..c0528fb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -31,8 +31,6 @@ bin_PROGRAMS = check-regexp source-highlight 
source-highlight-settings
 bin_SCRIPTS = java2html cpp2html src-hilite-lesspipe.sh \
        source-highlight-esc.sh
 
-EXTRA_PROGRAMS = source-highlight-cgi 
-
 SRCHILITE = $(top_builddir)/src/source-highlight$(EXEEXT)
 
 AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_builddir)/gl -I$(top_srcdir)/lib 
$(BOOST_CPPFLAGS)
@@ -41,7 +39,6 @@ AM_LDFLAGS = $(BOOST_LDFLAGS)
 LDADD = $(top_builddir)/gl/libgnu.la
 
 source_highlight_LDADD = $(LDADD) 
$(top_builddir)/lib/srchilite/libsource-highlight.la
-source_highlight_cgi_LDADD = $(source_highlight_LDADD)
 
 check_regexp_LDADD = $(BOOST_REGEX_LIB) $(top_builddir)/gl/libgnu.la
 
@@ -53,15 +50,12 @@ source_highlight_SOURCES = cmdline.c source-highlight.cc
 check_regexp_SOURCES = check-regexp_cmd.c check-regexp.cpp
 source_highlight_settings_SOURCES = source-highlight-settings.cpp
 
-source_highlight_cgi_SOURCES = cmdline.c source-highlight-cgi.cc envmapper.c
-
 # files that we don't want automake/autoconf to touch ever.
 # just stick them in the distribution as-is
 EXTRA_DIST = \
 java2html.in \
 cpp2html.in \
 src-hilite-lesspipe.sh.in \
-envmapper.h \
 cmdline.ggo check-regexp_cmd.ggo \
 $(source_highlightdata_DATA) \
 src.pro source-highlight.pro source-highlight-settings.pro
diff --git a/src/envmapper.c b/src/envmapper.c
deleted file mode 100644
index b3804d8..0000000
--- a/src/envmapper.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 1999, 2000, 2001  Lorenzo Bettini 
<http://www.lorenzobettini.it>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * src/envmapper.c -- maps QUERY_STRING environment to argv
- *
- * 19.04.2001 [SPX] * added __convert_string() and __convert_char() to
- *                    interpret '%XX' 'characters' of 'QUERY_STRING'
- *                  * checks for CGI by scanning REQUEST_METHOD
- *                  * 'QUERY_STRING' is determined by REQUEST_METHOD
- * 06.04.2001 [SPX] completed initial revision
- * 05.04.2001 [SPX] initial revision
- *
- * written by Robert Wetzel <[email protected]>
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-#include "envmapper.h"
-
-
-int
-__convert_char(char *hexstr, int *source)
-{
-  int i, ch, temp_ch;
-
-  for (ch = i = 0; i < 2; i++) {
-    temp_ch = hexstr[(*source)++];
-    if (!isxdigit(temp_ch))
-      return temp_ch;
-    temp_ch -= '0';
-    if (temp_ch > 9)
-      temp_ch -= 'A' - '9' - 1;
-    ch = (ch << 4) + temp_ch;
-  }
-  return ch;
-}
-
-char *
-__convert_string(char *hexstr)
-{
-  int source, dest, ch, len;
-
-  source = dest = 0;
-  len = strlen(hexstr);
-  while (source < len) {
-    if ((ch=hexstr[source++]) == '%')
-      hexstr[dest++] = __convert_char(hexstr, &source);
-    else
-      hexstr[dest++] = ch;
-  }
-  hexstr[dest] = '\0';
-  return hexstr;
-}
-
-char *
-__get_option_string(char *token)
-{
-  char *new_token;
-
-  new_token = (char*)calloc(strlen(token)+3, 1);
-  sprintf(new_token, "--%s", token);
-  return new_token;
-}
-
-char **
-map_environment(int *argc, char **argv)
-{
-  char *query_string, *request_method, *token;
-  char **new_argv;
-
-  /* check first, if CGI environment exists */
-  request_method = getenv(ENV_REQUEST_METHOD);
-  if (!request_method)
-    return argv;
-  /* Ok. There is a request method. Lets check how the 'arguments'
-     are given by determining the request method... */
-  if (!strcasecmp(request_method, REQUEST_METHOD_GET))
-    query_string = getenv(ENV_QUERY_STRING);
-  else {
-    query_string = (char*)calloc(MAX_QUERY_STRING_LEN, sizeof(char));
-    query_string = fgets(query_string, MAX_QUERY_STRING_LEN - 2, stdin);
-    if (query_string)
-      query_string[strlen(query_string)-2] = '\0';
-  }
-  if (!query_string)
-    /* print error page! Currently this looks like a security hole as
-       it switches back to command line mode. */
-    return argv;
-  query_string = __convert_string(query_string);
-  /* allocate memory for the new argv which may hold up to
-     MAX_PARAM_AMOUNT options */
-  new_argv = (char**)calloc(MAX_PARAM_AMOUNT, sizeof argv);
-  /* 'copy' parameter strings */
-  memcpy(new_argv, argv, *argc * sizeof argv);
-  token = strtok(query_string, "&");
-  do {
-    new_argv[(*argc)++] = __get_option_string(token);
-  }
-  while ((token = strtok(NULL, "&")));
-  return new_argv;
-}
diff --git a/src/envmapper.h b/src/envmapper.h
deleted file mode 100644
index 16a6a43..0000000
--- a/src/envmapper.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 1999, 2000, 2001  Lorenzo Bettini 
<http://www.lorenzobettini.it>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/* 
- * src/envmapper.h -- prototypes and definitions for src/envmapper.c
- *
- * 19.04.2001 [SPX] * added ENV_REQUEST_METHOD
- *                  * added MAX_QUERY_STRING_LEN
- *                  * added REQUEST_METHOD_GET
- * 06.04.2001 [SPX] completed initial revision
- * 05.04.2001 [SPX] initial revision
- *
- * written by Robert Wetzel <[email protected]>
- */
-
-#ifndef _ENVMAPPER_H__
-#define _ENVMAPPER_H__
-
-#define ENV_REQUEST_METHOD    "REQUEST_METHOD"
-#define ENV_QUERY_STRING      "QUERY_STRING"
-#define REQUEST_METHOD_GET    "GET"
-#define MAX_PARAM_AMOUNT      128
-#define MAX_QUERY_STRING_LEN  512
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-char **map_environment(int *argc, char **argv);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _ENVMAPPER_H__ */
diff --git a/src/source-highlight-cgi.cc b/src/source-highlight-cgi.cc
deleted file mode 100644
index e075f29..0000000
--- a/src/source-highlight-cgi.cc
+++ /dev/null
@@ -1,3 +0,0 @@
-#define BUILD_AS_CGI
-
-#include "source-highlight.cc"
diff --git a/src/source-highlight.cc b/src/source-highlight.cc
index 6f883e4..d871351 100644
--- a/src/source-highlight.cc
+++ b/src/source-highlight.cc
@@ -71,7 +71,6 @@ static void print_version();
 static string inferLang(const string &inputFileName);
 static string getMappedLang(const string &s, LangMap &langmap);
 static void printError(const string &s);
-static void print_cgi_header();
 
 /**
  * Exits for a generic error (i.e., file not found)
@@ -84,9 +83,6 @@ static string getLangFileName(InferPolicy infer, const string 
&inputFileName,
 static bool verbose = false;
 static bool failsafe = false;
 
-#ifdef BUILD_AS_CGI
-#include "envmapper.h"
-#endif // BUILD_AS_CGI
 /**
  * Print progress status information (provided --quiet is not specified)
  * @param message
@@ -96,15 +92,7 @@ static bool failsafe = false;
 int main(int argc, char * argv[]) {
     set_program_name(argv[0]);
     gengetopt_args_info args_info; // command line structure
-    bool is_cgi = false;
-
-#ifdef BUILD_AS_CGI
-    // map environment to parameters if used as CGI
-    char **temp_argv;
-    temp_argv = map_environment(&argc, argv);
-    is_cgi = temp_argv != argv;
-    argv = temp_argv;
-#endif // BUILD_AS_CGI
+
     if (cmdline_parser(argc, argv, &args_info) != 0) {
         // calls cmdline parser. The user gived bag args if it doesn't return 
-1
         return EXIT_FAILURE;
@@ -186,10 +174,6 @@ int main(int argc, char * argv[]) {
     if (args_info.output_given)
         outputFile = args_info.output_arg;
 
-    // for cgi force output to standard output
-    if (is_cgi)
-        outputFile = "STDOUT";
-
     if (args_info.src_lang_given)
         srcLang = args_info.src_lang_arg;
 
@@ -426,8 +410,7 @@ int main(int argc, char * argv[]) {
             exit(EXIT_FAILURE);
         }
 
-        // for cgi we can only process one file specified with --input
-        if (args_info.inputs_num && !is_cgi) {
+        if (args_info.inputs_num) {
             // the output file name is empty, but we don't want to generate to 
stdout
             sourcehighlight.setCanUseStdOut(false);
             // in case multiple input files were specified (without --input)
@@ -439,9 +422,6 @@ int main(int argc, char * argv[]) {
                 PROGRESSINFO("created " + 
sourcehighlight.createOutputFileName(args_info.inputs[i]) + "\n");
             }
         } else {
-            if (is_cgi)
-                print_cgi_header();
-
             // in case only one input file was specified with --input
             sourcehighlight.highlight(inputFile, outputFile, getLangFileName(
                     inferPolicy, inputFile, langFile, srcLang, langmap));
@@ -586,9 +566,3 @@ void exitError(const string &s) {
     printError(s);
     exit(EXIT_FAILURE);
 }
-
-void print_cgi_header() {
-    cout << "Content-type: text/html\n";
-    cout << "\n";
-}
-


_______________________________________________
Help-source-highlight mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-source-highlight

Reply via email to