[next] [prev] [prev-tail] [tail] [up]

## Chapter 11
CGI programming in Free Pascal

In these days of heavy WWW traffic on the Internet, CGI scripts have become an important topic in computer programming. While CGI programming can be done with almost any tool you wish, most languages aren’t designed for it. Perl may be a notable exception, but perl is an interpreted language, the executable is quite big, and hence puts a big load on the server machine.

Because of its simple, almost intuitive, string handling and its easy syntax, Pascal is very well suited for CGI programming. Pascal allows you to quickly produce some results, while giving you all the tools you need for more complex programming. The basic RTL routines in principle are enough to get the job done, but you can create, with relatively little effort, some units which can be used as a base for more complex CGI programming.

That’s why, in this chapter, we will discuss the basics of CGI in Free Pascal. In the subsequent, we will assume that the server for which the programs are created, are based upon the NCSA httpd WWW server, as the examples will be based upon the NCSA method of CGI programming1. They have been tested with the apache server on L I N U X, and the xitami server on WI N D O W S NT.

The two example programs in this chapter have been tested on the command line and worked, under the condition that no spaces were present in the name and value pairs provided to them.

There is however, a faster and generally better uncgi unit available, you can find it on the contributed units page of the Free Pascal web site. It uses techniques discussed here, but in a generally more efficient way, and it also provides some extra functionality, not discussed here.

11.1 Getting your data
Data coming through standard input.
Data passed through an environment variable
11.2 Producing output
11.3 I’m under Windows, what now ?

[next] [prev] [prev-tail] [front] [up]