C eval alpha1=%subst(c:i:1)
C select
C when alpha1='-'
C eval sign= -1
C when alpha1='.'
C eval indecimal='1'
C when alpha1 >='0' and alpha1 <= '9'
C eval wknum = wknum * 10 + number1
C if indecimal = '1'
C eval decpos = decpos + 1
C endif
C endsl
C enddo
C eval n = wknum * sign / 10 ** decpos
C return n
Pc2n E
**************************************************************************
* Compile-time array follows:
**************************************************************************
* A line MUST follow Content-type with only a single newline(x'15'). If
* this newline does not exist, Then NO data will be served to the client.
* This newline represents the end of the HTTP header and the data follows.
**CTDATA HTML
Content-type: text/html
<html>
<head>
<title>Sample AS/400 RPG program executed by HTTP Server as a CGI</title>
</head>
<body>
<h1>Sample AS/400 RPG program.</h1>
<br>
<br>
<p>This is sample output using AS/400 HTTP Server CGI APIs from an RPG
program. This program reads the input data from Query_String
environment variable when the Request_Method is GET and reads
standard input when the Request_Method is POST.
<p>Server input:<br>
<p>Environment variable - REQUEST_METHOD:
<p>Environment variable - SERVER_SOFTWARE:
</body>
</html>
Example of a C language server configuration API program
/*
This C source file is for compiling into the sample program
APISAMPLE.PGM. It invokes the new configuration file APIs
contained in SRVPGM QHTTPSVR/QZHBCONF to read in
a configuration file, and either replace an existing PORT
directive or to add a new one.
This code is written by IBM, and is intended only as a sample.
There is no implied support for this code, and it is not
a part of any IBM product. It can be freely copied, modified
and used in any way desired.
*/
#include <stdio.h>
Chapter6. Sample programs (in Java, C, and RPG) 105