01.06.2013 Views

IPC@CHIP Documentation - SC12 @CHIP-RTOS V1.10

IPC@CHIP Documentation - SC12 @CHIP-RTOS V1.10

IPC@CHIP Documentation - SC12 @CHIP-RTOS V1.10

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The interrupt declaration will motivate the compiler to emit code that sets the CPU's DS data segment register on<br />

entry to the procedure, thus allowing access to the Pascal program's data.<br />

The <strong>IPC<strong>@CHIP</strong></strong> Web server handles the call to a Pascal CGI function differently than it does the call to a C<br />

language CGI function. One input parameter is needed by all CGI functions, C or Pascal. This one parameter<br />

is a far pointer to a rpCgi type structure (or in Pascal, a record). When calling a C language CGI function this<br />

pointer is pushed onto the stack using a normal parameter passing mechanism. For Pascal CGI functions this<br />

pointer is instead passed in the CPU's ES:DI registers. Consequently this pointer must be recovered by the<br />

Pascal program. This can be done as follows:<br />

procedure CgiMini_Proc;interrupt;<br />

var<br />

ESreg : Integer;<br />

DIreg : Integer;<br />

CGIRequest : rpCGIptr;<br />

begin<br />

asm<br />

mov ax,es<br />

mov Esreg,ax<br />

mov ax,di<br />

mov DIreg,ax<br />

end;<br />

CGIRequest := ptr(ESreg,DIreg);<br />

............<br />

end;<br />

Installing a Pascal CGI procedure:<br />

Pascal CGI procedure must be installed at the start of the DOS program with the CGI_INSTALL_PAS API call.<br />

(CGI functions written in C must still be installed with the standard CGI_INSTALL API.)<br />

For better understanding of programming CGI with Turbo Pascal, we provide some example programs compiled<br />

with Borland Pascal 7.0.<br />

1. cgiMini.exe<br />

The CGI function installed by this program produces a HTML page which contains some of the request<br />

parameters.<br />

Examples for browser inputs:<br />

http://192.168.205.4/cgimini<br />

http://192.168.205.4/cgimini?Argument<br />

2. countcgi.exe<br />

We build a dynamic HTML page which contains the current value of a counter incremented in the main<br />

loop of the program.<br />

Browser input: http://192.168.205.4/countcgi<br />

End of document<br />

Page 377 / 400

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!