Subject: IIS, CGI, and GCC
From: [email-masked] (Chieh Cheng)

11 Jun 1998 10:17:27 -0700
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
To: [email-masked]

I have a problem with a CGI program compiled with GCC and ran under IIS. My
problem is the exact same problem as the problem listed in the archive at:
http://www.cygnus.com/ml/gnu-win32/1997-Oct/0293.html

However, the solution supplied to the original post is unsatisfactory,
because the problem is obviously not in the source code. The same source
code (unmodified) is compiled under both GCC and MS VC++. The one compiled
under VC++ works just fine, but not the GCC compiled program.

The thread in the archive apparently died without an answer. Can someone
help me with this problem? Any help would be greatly appreciated. I have
enclosed a copy of the code I wrote, in case, anyone like to proof to
themselves that the source code is just fine.

Source code:

#include <stdio.h>
#include <stdlib.h>

#define safenv(a) ((cp = getenv (a)) ? cp : empty)

char * cp;
char * empty = "<empty>";
char * EOL = "\n";

int main ()
{
  fprintf (stdout, "Content-Type: text/html");
  fprintf (stdout, EOL);
  fprintf (stdout, EOL);

  fprintf (stdout, "<html><head><title>whatever</title></head><body><pre>");
  fprintf (stdout, EOL);
  fprintf (stdout, "GATEWAY_INTERFACE = %s", safenv ("GATEWAY_INTERFACE"));
  fprintf (stdout, EOL);
  fprintf (stdout, "REQUEST_METHOD = %s", safenv ("SCRIPT_NAME"));
  fprintf (stdout, EOL);
  fprintf (stdout, "QUERY_STRING = %s", safenv ("QUERY_STRING"));
  fprintf (stdout, EOL);
  fprintf (stdout, "SERVER_SOFTWARE = %s", safenv ("SERVER_SOFTWARE"));
  fprintf (stdout, EOL);
  fprintf (stdout, "SERVER_NAME = %s", safenv ("SERVER_NAME"));
  fprintf (stdout, EOL);
  fprintf (stdout, "SERVER_PROTOCOL = %s", safenv ("SERVER_PROTOCOL"));
  fprintf (stdout, EOL);
  fprintf (stdout, "SERVER_PORT = %s", safenv ("SERVER_PORT"));
  fprintf (stdout, EOL);
  fprintf (stdout, "HTTP_USER_AGENT = %s", safenv ("HTTP_USER_AGENT"));
  fprintf (stdout, EOL);
  fprintf (stdout, "HTTP_ACCEPT = %s", safenv ("HTTP_ACCEPT"));
  fprintf (stdout, EOL);
  fprintf (stdout, "PATH_INFO = %s", safenv ("PATH_INFO"));
  fprintf (stdout, EOL);
  fprintf (stdout, "PATH_TRANSLATED = %s", safenv ("PATH_TRANSLATED"));
  fprintf (stdout, EOL);
  fprintf (stdout, "REMOTE_HOST = %s", safenv ("REMOTE_HOST"));
  fprintf (stdout, EOL);
  fprintf (stdout, "REMOTE_ADDR = %s", safenv ("REMOTE_ADDR"));
  fprintf (stdout, EOL);
  fprintf (stdout, "REMOTE_USER = %s", safenv ("REMOTE_USER"));
  fprintf (stdout, EOL);
  fprintf (stdout, "REMOTE_IDENT = %s", safenv ("REMOTE_IDENT"));
  fprintf (stdout, EOL);
  fprintf (stdout, "AUTH_TYPE = %s", safenv ("AUTH_TYPE"));
  fprintf (stdout, EOL);
  fprintf (stdout, "CONTENT_TYPE = %s", safenv ("CONTENT_TYPE"));
  fprintf (stdout, EOL);
  fprintf (stdout, "CONTENT_LENGTH = %s", safenv ("CONTENT_LENGTH"));
  fprintf (stdout, EOL);
  fprintf (stdout, "</pre></body></html>");
  fprintf (stdout, EOL);

  return 0;
}

CC
--
http://www.geocities.com/Area51/8145/
That's the ways of the world. What ya waiting for?
She has to be loved. Everybody needs somebody.

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".