[Coco] [Non-DoD Source] Coco Digest, Vol 172, Issue 22

William Carlin whcarlinjr at gmail.com
Tue Jan 10 18:41:55 EST 2017


Phillip,

Here is an example from the drivewire extras disk:

For this example, the inetd is going to be setup for a web server:

[/DD/SYS/ientd.conf]
80,runb,httpd

DriveWIre will be instructed to listen for connections on port 80.  When it
does, the coco runs the runb Basic09 runtime and runb loads and executes
the Basic09 program httpd.  The inconing serial connection is passed to the
httpd as the standard input.

[httpd.b09]
PROCEDURE httpd

(* HTTPD09 - process one http request, should be spawned by inetd *)


!    This program is free software: you can redistribute it and/or modify
!    it under the terms of the GNU General Public License as published by
!    the Free Software Foundation, either version 3 of the License, or
!    (at your option) any later version.

!    This program is distributed in the hope that it will be useful,
!    but WITHOUT ANY WARRANTY; without even the implied warranty of
!    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!    GNU General Public License for more details.


ON ERROR GOTO 99
BASE 0

DIM fp:BYTE
DIM errnum:BYTE
DIM req:STRING[255]
DIM target:STRING[255]
DIM lf:BYTE
DIM cr:BYTE
DIM inbyte:BYTE
DIM buffer(256):BYTE
TYPE RREGISTERS=CC,A,B:BYTE; DP:BYTE; X,Y,U:INTEGER
DIM rregs:RREGISTERS
DIM reqid:BYTE
DIM i,p:INTEGER
DIM httperr:STRING[40]
DIM dent(32):BYTE

lf=10
cr=13

(* turn off echo on the input path *)
(* this will be done by inetd in the future *)

(* get ss.opt *)
rregs.A = 0
rregs.B = 0
rregs.X = ADDR(buffer)
reqid = $8D
RUN SYSCALL(reqid,rregs)

(* set PD.EKO to 0 *)
buffer(4) = 0

(* set ss.opt *)
rregs.A = 0
rregs.B = 0
rregs.X = ADDR(buffer)
reqid = $8E
RUN SYSCALL(reqid,rregs)

(* read headers from client *)
REPEAT

    req = ""

    REPEAT
        GET #0,inbyte
        req = req + chr$(inbyte)
    UNTIL inbyte = 13 or EOF(#0)

    IF LEFT$(req,4) = "GET " THEN
        target = req
    ENDIF

UNTIL PEEK(ADDR(req)) = 13 OR EOF(#0)

(* just die if stdin is gone.. might help with hung runbs? *)
IF EOF(#0) THEN 99

(* fixup paths *)
IF left$(target,6) = "GET / " THEN
    req = "/DD/WWWROOT/index.html"
ELSE
    req = mid$(target,5,len(target) - 14)
ENDIF

IF right$(req,1) = "/" THEN
    req = left$(req,len(req)-1)
ENDIF

(* "security" checks *)
target = ""
FOR i=1 TO SIZE(req)
 inbyte=ASC(MID$(req,i,1))
 IF $40<inbyte AND inbyte<$60 THEN
     inbyte = inbyte + $20
 ENDIF
 target=target + CHR$(inbyte)
NEXT i
IF (SUBSTR("..",req) > 0) OR (SUBSTR("/sys/",target) > 0) THEN
    httperr = "403 Forbidden"
    GOTO 1000
ENDIF

(* /favicon.ico *)
IF (req = "/favicon.ico") THEN
    req = "/DD/WWWROOT/favicon.ico"
ENDIF

ON ERROR GOTO 100
OPEN #fp,req:READ
ON ERROR GOTO 50
httperr = "200 OK"
GOSUB 2000

IF RIGHT$(req,4) = ".htm" OR RIGHT$(req,5) = ".html" THEN
    PRINT "Content-Type: text/html"
ELSE
    IF RIGHT$(req,4) = ".jpg" THEN
        PRINT "Content-Type: image/jpeg"
    ELSE
        IF RIGHT$(req,4) = ".gif" THEN
            PRINT "Content-Type: image/gif"
        ELSE
            IF RIGHT$(req,4) = ".png" THEN
                PRINT "Content-Type: image/png"
            ELSE
                IF RIGHT$(req,4) = ".ico" THEN
                    PRINT "Content-Type: image/x-icon"
                    PRINT "Cache-Control: public, max-age=31536000"
                ELSE
                    PRINT "Content-Type: text/plain"
                ENDIF
            ENDIF
        ENDIF
    ENDIF
ENDIF

PUT #1,lf

(* send file contents *)
REPEAT

    rregs.A = fp
    rregs.Y = 256
    rregs.X = ADDR(buffer)
    reqid = $89
    RUN SYSCALL(reqid,rregs)

    rregs.A = 1
    rregs.X = ADDR(buffer)
    reqid = $8A
    RUN SYSCALL(reqid,rregs)

UNTIL EOF(#fp)

50 ON ERROR GOTO 99
CLOSE #fp

target = DATE$ + " 200 OK " + req
GOSUB 3000

99 END


100 ON ERROR GOTO 99
errnum := ERR

IF errnum = 214 THEN
    (* directory check *)
    ON ERROR GOTO 200
    OPEN #fp,req:READ+DIR
    ON ERROR GOTO 99

    httperr = "200 OK"
    GOSUB 2000
    PRINT "Content-Type: text/html"
    PUT #1,lf

    PRINT "<HTML><HEAD><TITLE>"
    PRINT "Directory of ";req
    PRINT "</TITLE></HEAD><BODY>"

    PRINT "<H3>Directory of ";req;"</H3>"
    PRINT "<HR>"

    REPEAT

        get #fp,dent

        IF dent(0) > 0 THEN

            target = ""
            inbyte = dent(0)
            i = 0
            WHILE inbyte < 128 AND i<29 DO

                target = target + chr$(inbyte)
                i = i + 1
                inbyte = dent(i)

            ENDWHILE

            target = target + chr$(inbyte - 128)

            IF target <> "." THEN
                PRINT "<A HREF=";req;"/";target;">";target;"</A>"
                PRINT "<br>"
            ENDIF

        ENDIF

    UNTIL EOF(#fp)
    CLOSE #fp

    GOSUB 2100
    PRINT "</BODY></HTML>"

    target = DATE$ + " 200 OK (dir) " + req
    GOSUB 3000
    END
ELSE
    IF errnum = 216 THEN
        httperr = "404 Not Found"
    ELSE
        IF errnum = 215 THEN
            httperr = "400 Bad Request"
        ELSE
            httperr = "500 Internal Server Error"
        ENDIF
    ENDIF

    GOTO 1000
ENDIF



200 ON ERROR GOTO 99
httperr = "403 Forbidden"
(* error result *)
1000 GOSUB 2000
PRINT "Content-Type: text/html"
PUT #1,lf

PRINT "<HTML>"
PRINT "<HEAD><TITLE>";httperr;"</TITLE></HEAD>"
PRINT "<BODY><H2>";httperr;"</H2>"
GOSUB 2100
PRINT "</BODY></HTML>"
target = DATE$ + " " + httperr + " " + req
GOSUB 3000
END


(* server headers *)
2000 PRINT "HTTP/1.1 ";httperr
PRINT "Server: CoCoHTTPD"
PRINT "Connection: close"
RETURN

(* footer *)
2100 PRINT "<br><HR><font face=Tahoma;Arial;Sans size=2><i>httpd09 version
1.1 -
 ";DATE$;"</i></font>"
RETURN


(* logging - string to log in target *)
3000 ON ERROR GOTO 3010
CREATE #fp,"/DD/LOG/httpd.log":WRITE
ON ERROR GOTO 3030
GOTO 3020
3010 ON ERROR GOTO 3040
OPEN #fp,"/DD/LOG/httpd.log":WRITE
ON ERROR GOTO 3030
(* getstat ss.siz *)
rregs.A = fp
rregs.B = $02
reqid = $8D
RUN SYSCALL(reqid,rregs)
(* seek to eof *)
rregs.A = fp
reqid = $88
RUN SYSCALL(reqid,rregs)
3020 WRITE #fp,target
3030 ON ERROR GOTO 3040
CLOSE #fp
3040 ON ERROR GOTO 99
RETURN

I hope this helps.

William



On Tue, Jan 10, 2017 at 12:45 PM, Taylor, Phillip L CIV <
Phillip.L.Taylor at uscg.mil> wrote:

> Robert
>
> I need a example in basic09 that shows me how:
>
> (1) Determine if data is available to be received?
> (2) How to receive the data?
> (3) How to send data.
>
> None of the links that you provide give me no examples of how to do it.
>
> Thanks
>
>
> -----Original Message-----
> From: Coco [mailto:coco-bounces at maltedmedia.com] On Behalf Of
> coco-request at maltedmedia.com
> Sent: Tuesday, January 10, 2017 1:18 AM
> To: coco at maltedmedia.com
> Subject: [Non-DoD Source] Coco Digest, Vol 172, Issue 22
>
> Send Coco mailing list submissions to   coco at maltedmedia.com  To
> subscribe or
> unsubscribe via the World Wide Web, visit
> https://urldefense.proofpoint.com/v2/url?u=https-3A__
> pairlist5.pair.net_mailman_listinfo_coco&d=CwIGaQ&c=
> 0NKfg44GVknAU-XkWXjNxQ&r=_wDO0Ub5GRKd_gN_Uz7gGyIfuv5XrYnarPGRxBtD3N0&m=
> qMd3yWY0B1ooRPOLq6MgLL0ZV2ovTus5telwFce_Ocg&s=
> B2u2ktBpZodR00MuwNnCMQSXzhHGKjFe6KU_sZpHydY&e=
> or, via email, send a message with subject or body 'help' to
> coco-request at maltedmedia.com  You can reach the person managing the list
> at
> coco-owner at maltedmedia.com  When replying, please edit your Subject line
> so it
> is more specific
> than "Re: Contents of Coco digest..."
>
> Today's Topics:
>
>    1. Re: First time using miniFlash and Drivewire - some
>       compatibility questions (Barry Nelson)
>    2. VCC & Drivewire Communications (Taylor, Phillip L CIV)
>    3. Re: First time using miniFlash and Drivewire - some
>       compatibility questions (Paulo Garcia)
>    4. Rs232.dll (Taylor, Phillip L CIV)
>    5. Re: Rs232.dll (Robert Gault)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 9 Jan 2017 01:48:44 -0500
> From: Barry Nelson <barry.nelson at amobiledevice.com>
> To: coco at maltedmedia.com
> Subject: Re: [Coco] First time using miniFlash and Drivewire - some
>         compatibility questions
> Message-ID: <1BFBD879-7171-4115-A0A1-D567A3751E05 at amobiledevice.com>
> Content-Type: text/plain; charset=us-ascii
>
> Ooops! Sorry, responded to the wrong thread, and in any case it looks like
> the
> problem is resolved in that thread anyway. Please ignore my previous post.
>
>
> ------------------------------
>
> Message: 2
> Date: Mon, 9 Jan 2017 15:59:40 +0000
> From: "Taylor, Phillip L CIV" <Phillip.L.Taylor at uscg.mil>
> To: "coco at maltedmedia.com" <coco at maltedmedia.com>
> Subject: [Coco] VCC & Drivewire Communications
> Message-ID:
>         <EAEE2A6BD007DB4A939CD0051C55719630685470 at EMO-EXCH-2302.
> main.ads.uscg.mil>
>
> Content-Type: text/plain; charset="utf-8"
>
> Hello
>
> I am currently using the current version of Drivewire and Vcc. Question if
> your writing a program in Rsdos or Os9 Level 2 how to you receive and send
> data our to the internet using Drivewire?
>
> The memory address used in the Rs232 pack is different to check if data is
> being received, Buffer is clear to send, send and receive data.
>
> Can you please send a copy of your response to Phillip.l.taylor at uscg.mil.
>
> Thanks
> Phil Taylor
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: smime.p7s
> Type: application/x-pkcs7-signature
> Size: 5379 bytes
> Desc: not available
> URL:
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__pairlist5.pair.net_
> pipermail_coco_attachments_20170109_60deb5a1_attachment-
> 2D0001.bin&d=CwIGaQ&c=0NKfg44GVknAU-XkWXjNxQ&r=_wDO0Ub5GRKd_gN_
> Uz7gGyIfuv5XrYnarPGRxBtD3N0&m=qMd3yWY0B1ooRPOLq6MgLL0ZV2ovTu
> s5telwFce_Ocg&s=NUnGiSowlBJTehhCNx0TfbTqJxwsj3yxSAsZvD12UB8&e=
>  >
>
> ------------------------------
>
> Message: 3
> Date: Mon, 9 Jan 2017 12:32:22 -0500
> From: Paulo Garcia <paulo.astuser at gmail.com>
> To: CoCoList for Color Computer Enthusiasts <coco at maltedmedia.com>
> Subject: Re: [Coco] First time using miniFlash and Drivewire - some
>         compatibility questions
> Message-ID:
>         <CA+1aitPft92xQ3JnjBFijs4wA_hg5eL5JdsH2fFZrK7J4jg7=Q at mail.
> gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> Oh, you had my hopes up for a second! :)
>
> On Mon, Jan 9, 2017 at 1:48 AM, Barry Nelson <barry.nelson at amobiledevice.
> com
> > wrote:
>
> > Ooops! Sorry, responded to the wrong thread, and in any case it looks
> > like the problem is resolved in that thread anyway. Please ignore my
> > previous post.
> >
> > --
> > Coco mailing list
> > Coco at maltedmedia.com
> > https://urldefense.proofpoint.com/v2/url?u=https-3A__pairlist5.pair.ne
> > t_mailman_listinfo_coco&d=CwIGaQ&c=0NKfg44GVknAU-XkWXjNxQ&r=_wDO0Ub5GR
> > Kd_gN_Uz7gGyIfuv5XrYnarPGRxBtD3N0&m=qMd3yWY0B1ooRPOLq6MgLL0ZV2ovTus5te
> > lwFce_Ocg&s=B2u2ktBpZodR00MuwNnCMQSXzhHGKjFe6KU_sZpHydY&e=
> >
>
>
>
> --
> --------------------------------------------
> Paulo
>
>
> ------------------------------
>
> Message: 4
> Date: Mon, 9 Jan 2017 18:30:24 +0000
> From: "Taylor, Phillip L CIV" <Phillip.L.Taylor at uscg.mil>
> To: "coco at maltedmedia.com" <coco at maltedmedia.com>
> Subject: [Coco] Rs232.dll
> Message-ID:
>         <EAEE2A6BD007DB4A939CD0051C557196306864A7 at EMO-EXCH-2302.
> main.ads.uscg.mil>
>
> Content-Type: text/plain; charset="utf-8"
>
> I have been looking for the file rs232.dll on the internet and I can not
> find it. Does anyone have a copy of it or know where I can download the
> file
> from?
>
> Thanks
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: smime.p7s
> Type: application/x-pkcs7-signature
> Size: 5379 bytes
> Desc: not available
> URL:
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__pairlist5.pair.net_
> pipermail_coco_attachments_20170109_06737757_attachment-
> 2D0001.bin&d=CwIGaQ&c=0NKfg44GVknAU-XkWXjNxQ&r=_wDO0Ub5GRKd_gN_
> Uz7gGyIfuv5XrYnarPGRxBtD3N0&m=qMd3yWY0B1ooRPOLq6MgLL0ZV2ovTu
> s5telwFce_Ocg&s=mp8zhfV2eDJyjWkGF3IW0uS5wOumSDDSNnCt80HWR_M&e=
>  >
>
> ------------------------------
>
> Message: 5
> Date: Mon, 9 Jan 2017 14:26:46 -0500
> From: Robert Gault <robert.gault at att.net>
> To: CoCoList for Color Computer Enthusiasts <coco at maltedmedia.com>
> Subject: Re: [Coco] Rs232.dll
> Message-ID: <5873E3F6.4090402 at att.net>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> Taylor, Phillip L CIV wrote:
> > I have been looking for the file rs232.dll on the internet and I can not
> > find it. Does anyone have a copy of it or know where I can download the
> file
> > from?
> >
> > Thanks
> >
> >
> >
> >
>
> Phillip,
>
> What do you want to use that .dll for? RS232 capability is built into the
> MESS
> and VCC emulators.
>
> Robert
>
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Coco mailing list
> Coco at maltedmedia.com
> https://urldefense.proofpoint.com/v2/url?u=https-3A__
> pairlist5.pair.net_mailman_listinfo_coco&d=CwIGaQ&c=
> 0NKfg44GVknAU-XkWXjNxQ&r=_wDO0Ub5GRKd_gN_Uz7gGyIfuv5XrYnarPGRxBtD3N0&m=
> qMd3yWY0B1ooRPOLq6MgLL0ZV2ovTus5telwFce_Ocg&s=
> B2u2ktBpZodR00MuwNnCMQSXzhHGKjFe6KU_sZpHydY&e=
>
>
> ------------------------------
>
> End of Coco Digest, Vol 172, Issue 22
> *************************************
>
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>
>


More information about the Coco mailing list