contents

intro
overview
requirements
cgi basics

dyno cgi
cgi headers
cgi parameters
accessing files
pipe basics
substitution basics
more substitution
table substitution

Dyno CGI: CGI Header

The first thing the CGI must return to the browser is the CGI header. The simplest and most common form is "Content-Type: text/html" followed by two CRLF's. You can accomplish this by calling:

PrintSimpleHeader();

That's it. You just need to call this at the beginning of your CGI.

If you need to produce a more complex header, you can build it yourself, or if you just need to specify a different content type (for example, if you are not return HTML data but rather another data type, such as a graphic image) you can just call:

PrintContentType(char* typeString);

When you call PrintSimpleHeader(), it uses this with the type string "text/html".

Normally you are not responsible for returning the HTTP result string that looks like this:

HTTP/1.0 200

because it is done by the web server. However, there is something called "non-parsed headers" (NPH) which is a way of configuring a server and a CGI such that the CGI is required to provide the HTTP result string. If you need to do this, you can call:

PrintNPHResult(int result);

where the result is a proper numeric code such as 200 for success, 404 for not found, etc.

Example

Here is a minimal Hello World program that uses Dyno CGI to deal with the CGI headers, as well as two Dyno CGI functions that print out the HTML syntax that is required to wrap your body content. (In addition to your body content, the output should include the <HTML>, <HEAD>, <TITLE>, and <BODY> tags. This is handled by PrintSimpleHTMLStart and PrintSimpleHTMLEnd. If you need to output more complex header tags and information, you should just print it out yourself.)

#include <stdio.h>
#include <string.h>

#include "dyno_cgi.h"

int main()
 {
 PrintSimpleHeader();
 PrintSimpleHTMLStart("Hello World Page");

 printf("Hello! This is CGI output.");

 PrintSimpleHTMLEnd();
 FlushOutput();
 }