/* <form action="/cgi-bin/samplec" method="POST"> */
/* <input type="Text" maxsize=80 size=20 name="Sample"> */
/* <input type="Submit" name="SampleData" value="Submit CGI script"> */
/* <br>Sample CGI program written in AS/400 ILE/C.<br> */
/* Type data and Click Submit to run a Sample program using ILE/C. */
/* </form> */
/* . */
/* . */
/* . */
/* Change the form method to "GET" when input data for sample CGI */
/* program comes from the QUERY_STRING environment variable. */
/* */
/* HTTP Server configuration: */
/* # Pass the html document in a library */
/* Pass /sampledoc /qsys.lib/websamp.lib/htmlfile.file/samplec.mbr */
/* # Allow CGI program to run. */
/* Map /cgi-bin/* /cgi-bin/*.pgm */
/* Exec /cgi-bin/* /qsys.lib/websamp.lib/* */
/* */
/* This program is invoked by a URL from a browser in the form: */
/* http://hostname/sampledoc */
/* */
/* Functions tested: Calls to Standard input and output using */
/* standard i/o c calls. This program uses */
/* fread(), putchar(), and printf(). It is */
/* designed to run on the AS/400 HTTP Server. */
/* */
/**********************************************************************/
#include <stdio.h> /* C-stdio library. */
#include <string.h> /* string functions. */
#include <stdlib.h> /* stdlib functions. */
#include <errno.h> /* errno values. */
#define LINELEN 80 /* Max length of line. */
/**********************************************************************/
/* */
/* Function Name: writeData() */
/* */
/* Descriptive Name: Function is used to print the data to the */
/* browser. The data is printed 80 characters/line to provide */
/* a neat and readable output. */
/* */
/* HTTP Server Environment variables: */
/* ---------------------------------- */
/* */
/* Standard Input: */
/* --------------- */
/* */
/* Standard Output: */
/* ---------------- */
/* All data directed to Standard output is sent using printf() or */
/* putchar(). Standard output is written with html text. */
/* */
/* */
/* Input: ptrToData : A pointer to the data to write to stdout. */
/* dataLen : Length of data buffer. */
/* */
/* Output: Data buffer written to stdout. */
/* */
/* Exit Normal: */
/* */
Chapter6. Sample programs (in Java, C, and RPG) 95