mirror of
https://github.com/bobbimanners/emailler.git
synced 2024-11-15 17:09:16 +00:00
190 lines
6.5 KiB
HTML
190 lines
6.5 KiB
HTML
<h1>BASIC ON BAILS <h1>
|
|
<h2>COMMAND SUMMARY</h2>
|
|
<table border=1>
|
|
<tr>
|
|
<th>Command</th>
|
|
<th>Descrption</th>
|
|
<th>Parameters</th>
|
|
<th>Example</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>IPCFG</td>
|
|
<td>Display the current IP stack configuration</td>
|
|
<td>none</td>
|
|
<td><li>IPCFG</td>
|
|
</tr>
|
|
<tr>
|
|
<td>MAC</td>
|
|
<td>Set the last 3 bytes of the MAC address. Top 3 bytes will always be "00:80:10".<br> This command
|
|
also resets the whole IP stack, so new IP address will need to be assigned (via MYIP or DHCP) after calling MAC</td>
|
|
<td>3 byte string</td>
|
|
<td><li>MAC "FOO" - MAC will become 00:80:10:46:4F:4F (in PETSCII, $46 is 'F' and $4F is 'O') </td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>DHCP</td>
|
|
<td>Use DHCP to assign IP address, netmask, default gateway and DNS server </td>
|
|
<td>none</td>
|
|
<td><li>DHCP</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>MYIP</td>
|
|
<td>Assign a new IP address</td>
|
|
<td><li>IP address (string)</td>
|
|
<td><li>MYIP"10.1.1.2"</td>
|
|
</tr>
|
|
<tr>
|
|
<td>NETMASK</td>
|
|
<td>Assign a new netmask</td>
|
|
<td><li>netmask (string)</td>
|
|
<td><li>NETMASK"255.255.255.0"</td>
|
|
</tr>
|
|
<tr>
|
|
<td>GATEWAY</td>
|
|
<td>Assign a new default gateway (router to send non-local traffic to)</td>
|
|
<td><li>gateway IP address (string)</td>
|
|
<td><li>GATEWAY"10.1.1.1"</td>
|
|
</tr>
|
|
<tr>
|
|
<td>DNS</td>
|
|
<td>Specify the DNS server to be used for resolving hostnames</td>
|
|
<td><li>DNS server IP address (string)</td>
|
|
<td><li>DNS"10.1.1.1"</td>
|
|
</tr>
|
|
<tr>
|
|
<td>PING</td>
|
|
<td>Sends a number of ICMP echo requests to the specified host. For each packet sent, if a response is received a "." is displayed, if an error occurs (including a timeout) then a "!" is displayed.</td>
|
|
<td><li>hostname or IP ddress (string)<li>[optional] number of PING request to be sent (1..255) - default is 3</td>
|
|
<td><li>PING"JAMTRONIX.COM"<li>PING"10.1.1.1",10</td>
|
|
</tr>
|
|
<tr>
|
|
<td>HTTPD</td>
|
|
<td>start listening on a TCP port for inbound HTTP requests. When a HTTP request is received, go to the specified
|
|
default line number, unless the request happens to be for a path that has previously been HOOKed</td>
|
|
<td><li>port number (1..65535)<li>line number (1..65535)</td>
|
|
<td><li>HTTPD80,100 - will listen on port 80 and GOTO line 100 when a HTTP request is received</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>HOOK</td>
|
|
<td>sociate the 'path' part of a URL with a BASIC line number to jump to when a request for the specified path is received</td>
|
|
<td><li>path (string) - must start with "/"<li>line number (1..65535)</td>
|
|
<td><li>HOOK"/HELLO",200 - line 200 will be executed if request for "/HELLO" is received </td>
|
|
</tr>
|
|
<tr>
|
|
<td>TYPE</td>
|
|
<td>change the HTTP Content Type field in the HTTP header
|
|
from the default "text/html" to whatever is specified. Be careful with
|
|
case - the remote end will be expecting ASCII not PETSCII! For this to be effective, it must
|
|
be set BEFORE any data is output with the ! or XSEND keywords</td>
|
|
<td><li>mime type (string)</td>
|
|
<td><li>TYPE"application/octet-stream"</td>
|
|
</tr>
|
|
<tr>
|
|
<td>STATUS</td>
|
|
<td>change the HTTP status line from default
|
|
"200 OK". Be careful you include the 3 digit code (as an ASCII string)
|
|
then a space then a free form status description (ASCII NOT PETSCII).
|
|
To be effective, it must be set BEFORE any data is output with the ! or XSEND keywords</td>
|
|
<td><li>HTTP status line (string)</td>
|
|
<td><li>STATUS"404 File Not Found"</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>!</td>
|
|
<td>Send specified string expression. If no
|
|
HTTP header has been sent yet, one will be sent now.
|
|
</i></td>
|
|
<td><li>string to output</td>
|
|
<td><li>!"<H1>HELLO WORLD</H1>"</td>
|
|
</tr>
|
|
<tr>
|
|
<td>XSEND</td>
|
|
<td>Send a file from the default drive. If the file does
|
|
not exist, then an error message will be sent to the remote browser. If no HTTP header has
|
|
been sent yet, one will be sent first.</td>
|
|
<td><li>filename (string)</td>
|
|
<td><li>XSEND"FAVICON.ICO"</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>YIELD</td>
|
|
<td>finish processing the current request, go back and wait for
|
|
another HTTP request.</td>
|
|
<td><li>none</td>
|
|
<td><li>YIELD</td>
|
|
</tr>
|
|
|
|
</table>
|
|
<h2>Magic Variables</h2>
|
|
The following BASIC variables are set by BASIC ON BAILS whenever a HTTP request is being handled.
|
|
<h3>PA$</h3>
|
|
Set to the "path" part of the HTTP request.
|
|
<h3>Query String Variables</h3>
|
|
For each variable in the query string part of the HTTP request,the value is
|
|
decoded and stuck into a BASIC string variable.
|
|
<br>
|
|
<br>
|
|
Only the first letter of the query string variable is significant,
|
|
i.e. query strings N, NA, NAME, all would map to N$.
|
|
<br>
|
|
<br>
|
|
If there are multiple query string variables that all start with the
|
|
same letter, the LAST such variable in the query string is the one
|
|
that would be effective
|
|
.e.g if BASIC ON BAILS is processing a HTTP request with a query string /FOO?N=1&NA=2?NAME=3 then
|
|
in the BASIC handler, N$ would be "3", and NA$ and NAME$ would be
|
|
empty (BASIC only treats first 2 chars as significant anyway, so NA$
|
|
is same as NAME$)
|
|
<br>
|
|
<h2>STARTUP</h2>
|
|
If you try and load BASIC ON BAILS twice (or some other BASIC extender before BASIC ON BAILS) you will get an 'insufficient memory' error.
|
|
<br>
|
|
<br>
|
|
|
|
After BASIC ON BAILS has been installed, it will attempt to load (and run) a file (from whatever device BASIC ON BAILS was loaded from itself) called "INDEX.BAS".
|
|
If this file does not exist, then BASIC ON BAILS will exit with 'FILE NOT FOUND ERROR IN 10". This error can be ignored - you can load any file you want from then, or type
|
|
in a new one, or even use the commands in interactive mode.
|
|
<br>
|
|
<br>
|
|
<h2>ERROR HANDLING</h2>
|
|
Before HTTPD is called, BASIC errors are treated normally, i.e. on a SYNTAX ERROR or TYPE MISMATCH error, an error will be displayed on the screen, and
|
|
program execution will stop. But once you have fired up HTTPD, any BASIC errors are displayed on the
|
|
screen AND passed back to the browser as a HTTP error, and are non-fatal i.e. the HTTPD loop will keep running. You can exit HTTPD by
|
|
pressing RUN/STOP though.
|
|
<h2>EXAMPLE</h2>
|
|
<pre>
|
|
|
|
5 MAC CHR$(192)+CHR$(29)+CHR$(85)
|
|
10 DHCP
|
|
20 HOOK"/HELLO",1000
|
|
25 FA$="/"+CHR$(102)+CHR$(97)+CHR$(118)+CHR$(105)+CHR$(99)+CHR$(111)
|
|
27 FA$=FA$+CHR$(110)+CHR$(46)+CHR$(105)+CHR$(99)+CHR$(111)
|
|
30 HOOKFA$,2000
|
|
40 HTTPD80,100
|
|
|
|
100 !"<H1>HELLO</H1>"
|
|
110 !"<FORM ACTION=/HELLO>"
|
|
120 !"WHAT'S YOUR NAME?"
|
|
130 !"<INPUT TYPE=TEXT NAME=N>"
|
|
140 !"</FORM>"
|
|
200 YIELD
|
|
|
|
1000!"HELLO "+N$+", I'M A C64 RUNNING BASIC ON BAILS."
|
|
1010 FOR I=1 TO 10
|
|
1020 !"<BR>"
|
|
1030 !STR$(I)
|
|
1040 NEXT I
|
|
1100 YIELD
|
|
|
|
2000 TYPE"IMAGE/X-ICON"
|
|
2010 XSEND"FAVICON.ICO"
|
|
2020 YIELD
|
|
|
|
|
|
</pre>
|
|
|
|
|