
DGI - Dos Gateway Interface
---------------------------

xChaos software anounces new chance for developers of DOS applications - DGI.

Today, there are crowds of programers of all ages, who know how to
write simple command-line text-mode applications in different programming
languages, including DOS shell (*.BAT), Basic, C, Turbo Pascal, etc.
But the common usage of window-oriented operating systems made it hard for
these programmers to make their programs easy-to use for common users, who are
expecting graphical interface.

However, there appeared new, even easier communication standart than windows
- WWW pages. It is both easier to use and easier to create than windows
applications, and it is possible to use also much more beautiful design.
(Note: I'm speaking about windows based interfaces generaly, not about
Micorosoft (TM) Windows (TM), also known as "Windoze", or "Wir95").
The application enviroment and word of explanation (help, manual) are
perfectly intgrated in WWW applications, based on so-called CGI (common
gateway interface). CGI is thousand times more popular than Java, partly
because all browsers support CGI forms, and partly because CGI scripts are
in fact simple text-mode applications in many different programming languages.

My idea is: you don't have to run CGI's on server - you can run it in DOS!
If you want do distribute CD-ROM with default WWW browser, and if you want
to use CGI scripts instead of Java or Javascript, you should try Arachne.
It will be called DGI (Dos Gateway Interface) instead of CGI (Common
Gateway Interface). Just copy your scripts from server to your PC and
run them ! (of course, the opposite process - developing of CGI in DOS
enviroment is also possible. DOS debugging tools are often more user friendly
than those running at Un*x command line...).

All you need is browser supporting DGI calls - for example Arachne.


What is DGI program ?
---------------------

DGI must be DOS executable (it means even *.BAT !) able to read standart CGI
query string from stdin or from file specified as program argument and must
be able to output HTML page to stdout or file specified as program argument.
DGI should work only with files and standart input/output; not with
video memory, either in text or graphics mode. That's all.


How to add DGI to Arachne ?
---------------------------

Arachne uses configuration file MIME.CFG for configuring plugins and DGI
applications. It will be necessary to write simple setup program for DGI
application which will ask for directory where Arachne and MIME.CFG is
installed and than modify it. It is simillar to installing Windows programs.

Line added in MIME.CFG can look for example like that:

file/myapp.cgi    >HTM|[200]c:\myapp\myapp.exe -q%s>%2

Syntax of MIME.CFG up to [200] symbol is not important; it is included
in the comments in MIME.CFG. The command line itself says: "Execute
c:\myapp\myapp.exe with at least 200 kb of DOS memory free, post the
CGI query string as an argument called -q and redirect output to file
with extension HTM which will be displayed after finishing program.

So the command assembled by Arachne can look for example like:

c:\myapp\myapp.exe -qSEARCHFOR=SOME+WORDS&MODE=1>TMP.HTM


How to add DGI to HTML pages ?
------------------------------

It is clear, that same HTML pages will be used on WWW server and in
DGI application. So for calling DGI described in previous example use
following <FORM> tag syntax:

<FORM ACTION="myapp.cgi">

After putting this page online, just create script "myapp.cgi" in the
same directory as the page is located and make it do the same job as
prgram myapp.exe.



Full MIME.CFG syntax
--------------------

Arachne uses standart mime types, and also special "DOS mime types"
called "file/...", because is DOS the file type is specified by extension.

-viewer plug-in:

mime_type   [save_extension]|command

(examples)

video/mpeg    MPG|@mpeg.exe %1
file/.mpg     |@mpeg.exe %1

-convertor plug-in or DGI:

mime_type   [original_extension]>new_extension|command

(examples)

file/*        >HTM|[150]htmldir -u%u>%2
file/dir.cgi  >HTM|[150]htmldir -u%u -q%s>%2
file/xapp.cgi >HTM|[100]c:\xapp\xapp.exe<%q>%2

-commands syntax:

prefix @   : set text mode and swap Arachne out
prefix [nn]: keep graphics mode and swap if there is less than [nn] kb free
no prefix  : keep graphics mode and always swap Arachne out

%1,$1 ... full input filename
%2,$2 ... full output filename
%u,$u ... url of document
%h,$h ... host (telnet://cyberspace.org -> cyberspace.org)
%d,$d ... file (ftp://ftp.vse.cz/pub/msdos/Arachne/ -> /pub/msdos/Arachne/)
%q,$q ... name of file with query string (is created only when using this macro)
%s,$s ... CGI compatible query string (max. 80 characters)
%c,$c ... full name of cache index (TOHLEUZ.MAM)
%h,$h ... history file (TADYJSEM.BYL)

%q, %1 and %2 can be nonexistent files, both plug-in (or DGI) and Arachne
must be prepared for everything. The only rule: it's ok to exit and do
nothing, as long as you do not crash the system.

See TESTDGI.HTM for more information.

CGI-QUERY syntax - open standart, already in use on Internet
-----------------

<variable_name>=[<value>][&<variable_name>=[<value>]...]

For example 'NAME=John+Brown&PHONE=123456'

Spaces are replaced with '+', non-alphanumeric charactes by sequence
'%NN', where NN is upercase hexadecimal ASCII code ('%0D' = 'Carriage return'
alias ASCII 13).
