home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 10
/
amigaformatcd10.iso
/
-in_the_mag-
/
html_tutorial
/
mas_env.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1996-09-03
|
3KB
|
71 lines
// (C) M.A.Smith University of Brighton
//
// Permission is granted to use this code
// provided this declaration and copyright notice remains intact.
//
// 26 August 1995 - April 7 1996
#include <iostream.h>
#include <fstream.h>
#include <iomanip.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
void cgi_var_output();
char* getenv_n( char [] );
// Output an HTML line
inline void html( char str[] ) { cout << str << "\n"; }
inline void html_( char str[] ) { cout << str; }
inline void html_( char c ) { cout << c; }
// Main program
int main()
{
html("Content-type: text/html"); html(""); // Type of output
cgi_var_output(); // Environment variables
return 0;
}
char* getenv_n( char var[] )
{
char *p = getenv( var ); // Contents
return p == NULL ? "[]" : p; // But it may not exist
}
void cgi_var_output( )
{
html( "<PRE>" );
html_("AUTH_TYPE "); html( getenv_n( "AUTH_TYPE" ) );
html_("CONTENT_LENGTH "); html( getenv_n( "CONTENT_LENGTH" ) );
html_("CONTENT_TYPE "); html( getenv_n( "CONTENT_TYPE" ) );
html_("GATEWAY_INTERFACE "); html( getenv_n( "GATEWAY_INTERFACE" ) );
html_("HOSTTYPE "); html( getenv_n( "HOSTTYPE" ) );
html_("HTTP_ACCEPT "); html( getenv_n( "HTTP_ACCEPT" ) );
html_("HTTP_CONNECTION "); html( getenv_n( "HTTP_CONNECTION" ) );
html_("HTTP_HOST "); html( getenv_n( "HTTP_HOST" ) );
html_("HTTP_PRAGMA "); html( getenv_n( "HTTP_PRAGMA" ) );
html_("HTTP_REFERER "); html( getenv_n( "HTTP_REFERER" ) );
html_("HTTP_USER_AGENT "); html( getenv_n( "HTTP_USER_AGENT" ) );
html_("OSTYPE "); html( getenv_n( "OSTYPE" ) );
html_("PATH_INFO "); html( getenv_n( "PATH_INFO" ) );
html_("PATH_TRANSLATED "); html( getenv_n( "PATH_TRANSLATED" ) );
html_("QUERY_STRING "); html( getenv_n( "QUERY_STRING" ) );
html_("REMOTE_ADDR "); html( getenv_n( "REMOTE_ADDR" ) );
html_("REMOTE_HOST "); html( getenv_n( "REMOTE_HOST" ) );
html_("REMOTE_IDENT "); html( getenv_n( "REMOTE_IDENT" ) );
html_("REMOTE_USER "); html( getenv_n( "REMOTE_USER" ) );
html_("REQUEST_METHOD "); html( getenv_n( "REQUEST_METHOD" ) );
html_("SCRIPT_NAME "); html( getenv_n( "SCRIPT_NAME" ) );
html_("SERVER_NAME "); html( getenv_n( "SERVER_NAME" ) );
html_("SERVER_PORT "); html( getenv_n( "SERVER_PORT" ) );
html_("SERVER_PROTOCOL "); html( getenv_n( "SERVER_PROTOCOL" ) );
html_("SERVER_SOFTWARE "); html( getenv_n( "SERVER_SOFTWARE" ) );
html( "</PRE>" );
}