Information passed from a web-server via an HTML form normally appears in environment variables. To get a listing of environment variables, use the following VC++ 6.0 code:
#include <stdlib.h>
#include <stdio.h>
// note that _environ is defined in stdlib.h as: extern char **_environ;
void main( void ) {
int i = 0;
while(_environ[i] != NULL) {
printf(" %3i. %s\n",i,_environ[i]);
i++;
}
}
Individual environment variables math be modified and accessed (with getenv and putenv) via the following:
/* GETENV.C: This program uses getenv to retrieve
* the LIB environment variable and then uses
* _putenv to change it to a new value.
*/
#include <stdlib.h>
#include <stdio.h>
void main( void )
{
char *libvar;
/* Get the value of the LIB environment variable. */
libvar = getenv( "LIB" );
if( libvar != NULL )
printf( "Original LIB variable is: %s\n", libvar );
/* Attempt to change path. Note that this only affects the environment
* variable of the current process. The command processor's environment
* is not changed.
*/
_putenv( "LIB=c:\\mylib;c:\\yourlib" );
/* Get new value. */
libvar = getenv( "LIB" );
if( libvar != NULL )
printf( "New LIB variable is: %s\n", libvar );
}
Output
Original LIB variable is: C:\progra~1\devstu~1\vc\lib
New LIB variable is: c:\mylib;c:\yourlib
There are a number of libraries available to process form information from web servers. They include:
|
Name |
Location |
Zipped Source (local) |
| libcppgi | http://sourceforge.net/projects/libcppgi/ | libcppgi-0.0.3.src.tar.gz |
| cgic | http://www.boutell.com/cgic/ | cgic107.zip |
| libstrfunc | http://sourceforge.net/projects/libstrfunc/ | libstrfunc-7.4.tar.gz |
| cgi4vb | http://www.freecode.com/projects/cgi4vb/ also | cgi4vb.zip |
/* SYSTEM.C: This program uses
* system to TYPE its source file.
*/
#include <process.h>
void main( void )
{
system( "type system.c" );
}
(zipped sample executable, VB project and sample web page)