A2osX/SBIN/HTTPD.S.txt

827 lines
14 KiB
Plaintext
Raw Normal View History

NEW
2019-05-02 09:52:32 +00:00
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
2020-05-08 19:02:27 +00:00
.TF sbin/httpd
*--------------------------------------
2020-05-30 20:38:47 +00:00
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/mli.i
2020-06-05 19:26:34 +00:00
.INB inc/mli.e.i
2020-05-30 20:38:47 +00:00
.INB inc/eth.i
.INB inc/libtcpip.i
.INB inc/net.http.i
*--------------------------------------
TIMEOUT.MAX .EQ 30 30 sec.
CONN.MAX .EQ 16
*--------------------------------------
2019-10-24 05:55:42 +00:00
.DUMMY
.OR ZPBIN
ZS.START
2020-05-30 20:38:47 +00:00
ZPPtr1 .BS 2
2020-06-05 19:26:34 +00:00
ZPPtr2 .BS 2
2019-10-24 05:55:42 +00:00
ZPSktPtr .BS 2
2020-05-30 20:38:47 +00:00
hFile .BS 1
2020-06-07 08:06:51 +00:00
hLineBuf .BS 1
2020-05-30 20:38:47 +00:00
hSrvSocket .BS 1
TimeOut .BS 1
2019-10-24 14:47:28 +00:00
2020-05-30 20:38:47 +00:00
hSrvName .BS 1
ZPSrvNamePtr .BS 2
2019-10-24 14:47:28 +00:00
hRootdir .BS 1
ZPRootDirPtr .BS 2
2020-05-30 20:38:47 +00:00
ZPRequestPtr .BS 2
ZPnRequestLen .BS 2
2020-06-05 19:26:34 +00:00
ZPLinePtr .BS 2
2020-05-30 20:38:47 +00:00
2020-06-05 19:26:34 +00:00
ZPRepPtr .BS 2
2019-10-24 14:47:28 +00:00
2019-10-24 05:55:42 +00:00
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
2019-03-02 20:47:58 +00:00
.DA #S.PS.F.EVENT
.DA #0
.DA CS.END-CS.START CS
.DA DS.END-DS.START DS
.DA #64 SS
2019-10-24 05:55:42 +00:00
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
* Relocation Table
2019-10-03 06:25:27 +00:00
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.LIBTCPIP .DA LIBTCPIP
2020-05-30 20:38:47 +00:00
L.ETCHTTPDCONF .DA ETCHTTPDCONF
2020-06-05 19:26:34 +00:00
L.KEYWORDS.CONF .DA KEYWORDS.CONF
J.KEYWORDS.CONF .DA CS.RUN.CONF.SERVERNAME
2020-05-30 20:38:47 +00:00
.DA CS.RUN.CONF.LISTEN
.DA CS.RUN.CONF.DOCUMENTROOT
2019-03-02 22:18:21 +00:00
L.SA.Local .DA SA.Local
L.MSG.TCPWAIT .DA MSG.TCPWAIT
L.MSG.TCPIPERR .DA MSG.TCPIPERR
2020-05-30 20:38:47 +00:00
L.MSG.INITCONF .DA MSG.INITCONF
2019-10-24 14:47:28 +00:00
L.MSG.INITOK .DA MSG.INITOK
L.MSG.SKTERR .DA MSG.SKTERR
L.MSG.INCOMING .DA MSG.INCOMING
2020-06-07 08:06:51 +00:00
L.MSG.REQ .DA MSG.REQ
2020-06-09 13:40:21 +00:00
L.MSG.FILE .DA MSG.FILE
2020-06-07 08:06:51 +00:00
L.MSG.SKTCLOSE .DA MSG.SKTCLOSE
2020-06-05 19:26:34 +00:00
L.KEYWORDS.REQ .DA KEYWORDS.REQ
J.KEYWORDS.REQ .DA CS.RUN.REQ.GET
L.INDEX.HTML .DA INDEX.HTML
L.MIME.TYPES .DA MIME.TYPES
T.MIME .DA MIME.HTML
.DA MIME.TXT
2020-06-05 19:43:14 +00:00
.DA MIME.TTF
2020-06-05 19:26:34 +00:00
.DA MIME.ICO
.DA MIME.PNG
.DA MIME.JPG
L.MIME.DEFAULT .DA MIME.DEFAULT
L.HTTP.200 .DA HTTP.200
L.HTTP.404 .DA HTTP.404
2019-10-03 06:25:27 +00:00
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBTCPIP
2018-07-19 15:33:55 +00:00
>SYSCALL LoadLib
2019-03-04 07:14:31 +00:00
bcs .9
sta hLIBTCPIP
2019-03-04 07:14:31 +00:00
.9 rts
*--------------------------------------
2019-10-24 05:55:42 +00:00
CS.RUN >LDYA L.MSG.TCPWAIT
2020-02-28 07:21:46 +00:00
>SYSCALL PutS
2019-10-24 14:47:28 +00:00
lda #TIMEOUT.MAX
sta TimeOut
2019-10-24 05:55:42 +00:00
2019-03-04 07:14:31 +00:00
.1 >SLEEP
>LIBCALL hLIBTCPIP,LIBTCPIP.GETCFG is TCPIP loaded ?
bcs .99
2019-10-24 05:55:42 +00:00
2020-05-30 20:38:47 +00:00
>STYA ZPPtr1
lda (ZPPtr1) Configured ?
bmi CS.RUN.INIT
2019-10-24 05:55:42 +00:00
2019-10-24 14:47:28 +00:00
lda Timeout
2019-03-04 07:14:31 +00:00
bcs .99
2019-10-24 05:55:42 +00:00
2019-03-04 07:14:31 +00:00
ldy #S.PS.hStdIn
2020-02-28 07:21:46 +00:00
lda (pPS),y
2019-03-04 07:14:31 +00:00
>SYSCALL feof
bcs CS.RUN.RTS I/O err
tay
2019-05-02 09:52:32 +00:00
bne .1
2019-03-04 07:14:31 +00:00
>SYSCALL GetChar
2019-03-04 07:14:31 +00:00
bcs CS.RUN.RTS
2020-05-30 20:38:47 +00:00
cmp #3 Ctrl-C
bne .1
2019-10-24 05:55:42 +00:00
sec
rts
2019-10-24 05:55:42 +00:00
.99 >LDYA L.MSG.TCPIPERR
2020-02-28 07:21:46 +00:00
>SYSCALL PutS
2019-10-24 14:47:28 +00:00
CS.RUN.SYN
2018-10-21 20:54:07 +00:00
lda #E.SYN
sec
CS.RUN.RTS rts
2020-06-07 08:06:51 +00:00
*--------------------------------------
CS.RUN.INIT ldx #3
ldy #S.IPCFG.IP+3
2019-10-24 05:55:42 +00:00
2020-05-30 20:38:47 +00:00
.1 lda (ZPPtr1),y
2019-03-02 22:18:21 +00:00
sta SA.LOCAL+S.SOCKADDR.ADDR,x
dey
dex
bpl .1
2019-10-24 14:47:28 +00:00
2020-05-30 20:38:47 +00:00
>LDYAI 256
>SYSCALL GetMem
bcs CS.RUN.RTS
2019-10-24 14:47:28 +00:00
2020-06-05 19:26:34 +00:00
>STYA ZPLinePtr
2020-06-07 08:06:51 +00:00
stx hLineBuf
2020-05-30 20:38:47 +00:00
>PUSHW L.MSG.INITCONF
>PUSHW L.ETCHTTPDCONF
>PUSHBI 2
>SYSCALL PrintF
2019-10-24 14:47:28 +00:00
bcs CS.RUN.RTS
2020-05-30 20:38:47 +00:00
jsr CS.RUN.CONF
bcs CS.RUN.RTS
>PUSHBI 0 no protocol
2020-06-07 13:47:00 +00:00
lda #S.SOCKET.T.SEQPKT
2019-03-02 22:18:21 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Socket
2020-05-08 19:02:27 +00:00
bcs CS.RUN.RTS
2018-09-17 15:42:38 +00:00
2019-10-24 14:47:28 +00:00
sta hSrvSocket
2019-03-02 22:18:21 +00:00
>PUSHW L.SA.LOCAL
2019-10-24 14:47:28 +00:00
lda hSrvSocket
2019-03-02 22:18:21 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Bind
bcs CS.RUN.ERR
2019-10-24 14:47:28 +00:00
lda hSrvSocket
2019-03-02 22:18:21 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Listen
bcs CS.RUN.ERR
2019-10-24 05:55:42 +00:00
2020-02-14 07:21:56 +00:00
>PUSHW L.MSG.INITOK
2019-10-24 14:47:28 +00:00
>PUSHW SA.LOCAL+S.SOCKADDR.PORT
2020-02-14 07:21:56 +00:00
>PUSHW ZPRootDirPtr
2019-10-24 14:47:28 +00:00
>PUSHBI 4
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2020-06-07 08:06:51 +00:00
*--------------------------------------
CS.RUN.LOOP >SLEEP
jsr CS.RUN.SERVER
bcs CS.RUN.ERR
bra CS.RUN.LOOP
2019-10-24 05:55:42 +00:00
2020-06-07 08:06:51 +00:00
CS.RUN.ERR >LDYA L.MSG.SKTERR
2020-02-28 07:21:46 +00:00
>SYSCALL PutS
2018-10-21 20:54:07 +00:00
lda #E.SYN
sec
2020-06-07 08:06:51 +00:00
rts
*--------------------------------------
2020-05-30 20:38:47 +00:00
CS.RUN.CONF >PUSHW L.ETCHTTPDCONF
>PUSHBI O.RDONLY+O.TEXT
>PUSHBI S.FI.T.TXT
>PUSHWZ
>SYSCALL FOpen
bcs .99
sta hFile
.1 >PUSHWI 256
2020-06-05 19:26:34 +00:00
>PUSHW ZPLinePtr
2020-05-30 20:38:47 +00:00
lda hFile
>SYSCALL fgets
bcs .8
tya
beq .1
2020-06-05 19:26:34 +00:00
lda (ZPLinePtr)
2020-05-30 20:38:47 +00:00
cmp #'#'
beq .1
2020-06-05 19:26:34 +00:00
>LDYA L.KEYWORDS.CONF
2020-05-30 20:38:47 +00:00
>STYA ZPPtr1
ldx #0
.2 ldy #0
.3 lda (ZPPtr1),y
2020-06-05 19:26:34 +00:00
cmp (ZPLinePtr),y
2020-05-30 20:38:47 +00:00
bne .4
iny
cmp #C.SPACE
bne .3
jsr CS.RUN.CONF.JMP
bcc .1
bra .97
.4 inx
inx
ldy #0
.5 iny
lda (ZPPtr1),y
cmp #C.SPACE
bne .5
tya
sec
adc ZPPtr1
sta ZPPtr1
bcc .6
inc ZPPtr1+1
.6 lda (ZPPtr1)
bne .2
.97 lda #E.SYN
.98 pha
jsr .8
pla
sec
.99 rts
.8 lda hFile
>SYSCALL FClose
rts
*--------------------------------------
CS.RUN.CONF.JMP tya
clc
2020-06-05 19:26:34 +00:00
adc ZPLinePtr
2020-05-30 20:38:47 +00:00
sta ZPPtr1
tay
lda #0
2020-06-05 19:26:34 +00:00
adc ZPLinePtr+1
2020-05-30 20:38:47 +00:00
sta ZPPtr1+1
2020-06-05 19:26:34 +00:00
jmp (J.KEYWORDS.CONF,x)
2020-05-30 20:38:47 +00:00
CS.RUN.CONF.SERVERNAME
>SYSCALL StrDup
bcs .9
>STYA ZPSrvNamePtr
stx hSrvName
.9 rts
CS.RUN.CONF.LISTEN
>SYSCALL atoi
bcs .9
>STYA SA.LOCAL+S.SOCKADDR.PORT
.9 rts
CS.RUN.CONF.DOCUMENTROOT
>PUSHYA
>PUSHWI 0 Allocate
>SYSCALL RealPath
bcs .9
>STYA ZPRootDirPtr
stx hRootdir
.9 rts
*--------------------------------------
2019-10-24 14:47:28 +00:00
CS.RUN.SERVER lda hSrvSocket
2019-03-02 22:18:21 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.accept
bcs .8
2019-10-24 14:47:28 +00:00
2020-06-07 08:06:51 +00:00
>STA.G CLN.hSocket
2019-03-02 22:18:21 +00:00
>SYSCALL GetMemPtr
>STYA ZPSktPtr
2020-02-14 07:21:56 +00:00
>PUSHW L.MSG.INCOMING
2019-10-24 05:55:42 +00:00
2020-06-07 08:06:51 +00:00
>PUSHB.G CLN.hSocket
2020-02-14 07:21:56 +00:00
ldx #3
ldy #S.SOCKET.REM.ADDR
2019-10-24 05:55:42 +00:00
2020-02-14 07:21:56 +00:00
.1 >PUSHB (ZPSktPtr),y
iny
dex
bpl .1
2019-03-02 22:18:21 +00:00
>PUSHBI 5
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2019-03-02 22:18:21 +00:00
2019-03-04 07:14:31 +00:00
jsr CS.RUN.CLIENT
2020-06-05 19:26:34 +00:00
.8 clc
2020-06-07 08:06:51 +00:00
.9
CS.RUN.SERVER.RTS
rts
*--------------------------------------
2020-06-07 08:06:51 +00:00
CS.RUN.CLIENT >LDYAI 1024
>SYSCALL GetMem
bcs CS.RUN.SERVER.RTS
>STYA ZPRepPtr
txa
2020-06-07 13:47:00 +00:00
>STA.G REP.hBuf
2020-06-07 08:06:51 +00:00
.10 >STZ.G REQ.FullPath
>STA.G REQ.hReq
>STA.G REQ.KeepAlive
2020-06-05 19:26:34 +00:00
>STA.G REQ.hFile
>STA.G REQ.hBuf
2019-03-04 07:14:31 +00:00
.1 >SLEEP
2020-06-07 08:06:51 +00:00
>LDA.G CLN.hSocket
2019-10-24 05:55:42 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Recv
2019-03-07 20:40:06 +00:00
bcc .2
2019-10-24 05:55:42 +00:00
tay
2019-03-07 20:40:06 +00:00
beq .1
2020-06-09 13:40:21 +00:00
jmp .99
2020-06-05 19:26:34 +00:00
2020-06-07 08:06:51 +00:00
.2 jsr CS.RUN.REQ.GetReq
2020-06-05 19:26:34 +00:00
.3 jsr CS.RUN.REQ.GetLine
bcs .4
>LDYA ZPLinePtr
>STYA ZPPtr2
>LDYA L.KEYWORDS.REQ
jsr CS.RUN.GET.KW
bcs .3
jsr CS.RUN.REQ.JMP
bcc .3
2020-06-09 13:40:21 +00:00
bcs .98
.4 >LDA.G REQ.hReq
>SYSCALL FreeMem
2020-06-05 19:26:34 +00:00
2020-06-09 13:40:21 +00:00
>STZ.G REQ.hReq
>LDA.G REQ.FullPath
2020-06-05 19:26:34 +00:00
beq .9
jsr CS.RUN.OpenFile
bcs .9
jsr CS.RUN.SendFile
2020-06-09 13:40:21 +00:00
bcs .99
2020-06-07 13:47:00 +00:00
2020-06-09 13:40:21 +00:00
bra .8
2019-10-24 05:55:42 +00:00
2020-06-05 19:26:34 +00:00
.9 >PUSHWI HTTP.404.len
>PUSHW L.HTTP.404
2020-06-07 08:06:51 +00:00
>LDA.G CLN.hSocket
2020-06-05 19:26:34 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Send
.8 >LDA.G REQ.KeepAlive
2020-06-09 13:40:21 +00:00
beq .99
2020-06-07 08:06:51 +00:00
jmp .10
2020-06-05 19:26:34 +00:00
2020-06-09 13:40:21 +00:00
.98 >LDA.G REQ.hReq
beq .99
>SYSCALL FreeMem
.99 >LDA.G REP.hBuf
2020-06-07 08:06:51 +00:00
>SYSCALL freemem
2020-06-07 13:47:00 +00:00
>PUSHW L.MSG.SKTCLOSE
2020-06-07 08:06:51 +00:00
>PUSHB.G CLN.hSocket
>PUSHBI 1
>SYSCALL printf
>LDA.G CLN.hSocket
2020-06-05 19:26:34 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown
2020-06-07 13:47:00 +00:00
rts
2020-06-05 19:26:34 +00:00
*--------------------------------------
2020-06-07 08:06:51 +00:00
CS.RUN.REQ.GetReq
>STA.G REQ.hReq
2020-05-30 20:38:47 +00:00
>SYSCALL GetMemPtr
>STYA ZPRequestPtr
2020-06-07 08:06:51 +00:00
>PUSHW L.MSG.REQ
>PUSHB.G REQ.hReq
>PUSHB.G CLN.hSocket
>PUSHBI 2
>SYSCALL printf
2020-05-30 20:38:47 +00:00
ldy #S.IP.TOTAL.LENGTH+1
lda (ZPRequestPtr),y
sec
sbc #S.TCP-S.IP
eor #$ff
sta ZPnRequestLen
dey
lda (ZPRequestPtr),y
sbc /S.TCP-S.IP
eor #$ff
sta ZPnRequestLen+1
lda ZPRequestPtr
clc
adc #S.TCP
sta ZPRequestPtr
2020-06-05 19:26:34 +00:00
bcc .8
2020-05-30 20:38:47 +00:00
inc ZPRequestPtr+1
2020-06-05 19:26:34 +00:00
.8 rts
*--------------------------------------
2020-06-05 19:26:34 +00:00
CS.RUN.REQ.GetLine
2019-10-24 14:47:28 +00:00
ldy #0
2020-05-30 20:38:47 +00:00
.1 inc ZPnRequestLen
2019-10-24 14:47:28 +00:00
bne .2
2020-05-30 20:38:47 +00:00
inc ZPnRequestLen+1
2019-10-24 14:47:28 +00:00
beq .9
2020-05-30 20:38:47 +00:00
.2 lda (ZPRequestPtr)
inc ZPRequestPtr
2019-10-24 14:47:28 +00:00
bne .21
2020-05-30 20:38:47 +00:00
inc ZPRequestPtr+1
2019-10-24 14:47:28 +00:00
.21 cmp #C.CR
bne .4
2020-05-30 20:38:47 +00:00
inc ZPnRequestLen
2019-10-24 14:47:28 +00:00
bne .3
2020-05-30 20:38:47 +00:00
inc ZPnRequestLen+1
2019-10-24 14:47:28 +00:00
beq .9
2020-05-30 20:38:47 +00:00
.3 lda (ZPRequestPtr)
inc ZPRequestPtr
2019-10-24 14:47:28 +00:00
bne .31
2020-05-30 20:38:47 +00:00
inc ZPRequestPtr+1
2019-10-24 14:47:28 +00:00
.31 eor #C.LF
bne .9
2020-06-05 19:26:34 +00:00
sta (ZPLinePtr),y Y,A = StrLen
2019-10-24 14:47:28 +00:00
clc
rts
2020-06-05 19:26:34 +00:00
.4 sta (ZPLinePtr),y
2019-10-24 14:47:28 +00:00
iny
bra .1
.9 sec
rts
*--------------------------------------
2020-06-09 13:40:21 +00:00
CS.RUN.OpenFile >PUSHW L.MSG.FILE
>PUSHB.G CLN.hSocket
>PUSHEA.G REQ.FullPath
>PUSHBI 3
>SYSCALL printf
2020-06-05 19:26:34 +00:00
>PUSHEA.G REQ.FullPath
>PUSHBI O.RDONLY
>PUSHBI 0 type
>PUSHWZ Aux type
>SYSCALL FOpen
bcs .9
txa
>STA.G REQ.hFile
>PUSHA
>PUSHEA.G REQ.Stat
>SYSCALL FStat
2020-06-07 08:06:51 +00:00
>LEA.G REQ.FullPath
2020-06-05 19:26:34 +00:00
>STYA ZPPtr2
ldx #$ff
ldy #$ff
.1 iny
lda (ZPPtr2),y
beq .2
cmp #'.'
bne .1
tya
tax
bra .1
.2 txa
bpl .3
lda #MIME.DEFAULT.ID
bra .8
.3 sec
adc ZPPtr2
sta ZPPtr2
bcc .4
inc ZPPtr2+1
.4 >LDYA L.MIME.TYPES
jsr CS.RUN.GET.KW
txa
.8 >STA.G REQ.MimeType
clc
2020-06-07 08:06:51 +00:00
.9 rts
2020-06-05 19:26:34 +00:00
*--------------------------------------
CS.RUN.SendFile >PUSHW ZPRepPtr
>PUSHW L.HTTP.200
>LDA.G REQ.MimeType
tax
>PUSHW T.MIME,x
>PUSHL.G REQ.Stat+S.STAT.SIZE
>PUSHBI 6
>SYSCALL SPrintf
bcs .9
jsr CS.RUN.SendBuf Y,A = car count
.1 >PUSHWI 1024
>PUSHW ZPRepPtr
>LDA.G REQ.hFile
>SYSCALL fread
bcs .8
jsr CS.RUN.SendBuf
2020-06-07 13:47:00 +00:00
bcs .9
2020-06-05 19:26:34 +00:00
2020-06-07 13:47:00 +00:00
bra .1
2020-06-05 19:26:34 +00:00
.8 cmp #MLI.E.EOF
bne .9
clc
2020-06-07 13:47:00 +00:00
.9 php
pha
>LDA.G REQ.hFile
>SYSCALL FClose
pla
plp
rts
2020-06-05 19:26:34 +00:00
*--------------------------------------
CS.RUN.SendBuf >PUSHYA
>PUSHW ZPRepPtr
2020-06-07 08:06:51 +00:00
>LDA.G CLN.hSocket
2020-06-05 19:26:34 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Send
rts
*--------------------------------------
CS.RUN.REQ.JMP jmp (J.KEYWORDS.REQ,x)
*--------------------------------------
CS.RUN.REQ.GET ldy #0
.1 iny
lda (ZPPtr2),y
eor #C.SPACE
bne .1
sta (ZPPtr2),y
lda (ZPPtr2)
cmp #'/'
bne .4
>PUSHW ZPRootDirPtr
>LEA.G REQ.FullPath
>SYSCALL StrCpy
ldy #1
lda (ZPPtr2),y
bne .2
>LDYA L.INDEX.HTML
bra .3
.2 >LDYA ZPPtr2
.3 >PUSHYA
>LEA.G REQ.FullPath
>SYSCALL StrCat
rts
.4 >PUSHW ZPPtr2
>PUSHEA.G REQ.FullPath
>SYSCALL realpath
.9 rts
*--------------------------------------
CS.RUN.REQ.Connection
lda (ZPPtr2)
eor #'k'
beq .1
lda #$ff
.1 >STA.G REQ.KeepAlive
clc
rts
*--------------------------------------
CS.RUN.GET.KW >STYA ZPPtr1
ldx #0
.2 ldy #$ff
.3 iny
lda (ZPPtr1),y
cmp (ZPPtr2),y
bne .4
cmp #0
beq .33
cmp #C.SPACE
bne .3
.33 tya
sec
adc ZPPtr2
sta ZPPtr2
bcc .8
inc ZPPtr2+1
.8 clc
rts
.4 inx
inx
ldy #0
.5 iny
lda (ZPPtr1),y
bne .5
tya
sec
adc ZPPtr1
sta ZPPtr1
bcc .6
inc ZPPtr1+1
.6 lda (ZPPtr1)
bne .2
sec
2020-05-30 20:38:47 +00:00
rts
*--------------------------------------
2019-03-04 07:14:31 +00:00
CS.DOEVENT lda (pEvent)
bpl .9 is it a TIMER event?
2019-10-24 14:47:28 +00:00
lda TimeOut
2019-03-04 07:14:31 +00:00
beq .9
2019-10-24 14:47:28 +00:00
dec TimeOut
2019-03-04 07:14:31 +00:00
.9 sec do not discard TIMER event
rts
*--------------------------------------
2019-10-24 14:47:28 +00:00
CS.QUIT lda hSrvSocket
2020-05-30 20:38:47 +00:00
beq .1
2019-10-24 05:55:42 +00:00
2019-03-02 22:18:21 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown
2019-10-24 05:55:42 +00:00
2020-06-07 08:06:51 +00:00
.1 lda hLineBuf
2020-05-30 20:38:47 +00:00
beq .2
>SYSCALL FreeMem
.2
lda hLIBTCPIP
2018-11-12 09:22:06 +00:00
beq .8
2019-10-24 05:55:42 +00:00
2018-07-20 14:10:10 +00:00
>SYSCALL UnloadLib
2019-10-24 05:55:42 +00:00
2018-11-12 09:22:06 +00:00
.8 clc
rts
*--------------------------------------
CS.END
*--------------------------------------
hLIBTCPIP .BS 1
2019-12-03 15:42:17 +00:00
LIBTCPIP .AZ "libtcpip"
2020-05-30 20:38:47 +00:00
ETCHTTPDCONF .AZ "${BOOT}etc/httpd.conf"
*--------------------------------------
2020-06-05 19:26:34 +00:00
KEYWORDS.CONF .AS "ServerName "
2020-05-30 20:38:47 +00:00
.AS "Listen "
.AS "DocumentRoot "
.DA #0
*--------------------------------------
2019-03-04 07:14:31 +00:00
MSG.TCPWAIT .AZ "HTTPD:Waiting for TCP/IP initializing..."
MSG.TCPIPERR .AZ "HTTPD:TCP/IP Not initialized properly."
2020-05-30 20:38:47 +00:00
MSG.INITCONF .AZ "HTTPD:Reading %s file...\r\n"
2019-10-24 14:47:28 +00:00
MSG.INITOK .AZ "HTTPD:Listening on port %D, root dir: %s.\r\n"
2020-06-07 08:06:51 +00:00
MSG.SKTERR .AZ "HTTPD:Skt Bind Error."
MSG.INCOMING .AZ "HTTPD:Skt $%h Opened From %d.%d.%d.%d\r\n"
MSG.REQ .AZ "HTTPD:Req $%h From Skt $%h\r\n"
2020-06-09 13:40:21 +00:00
MSG.FILE .AZ "HTTPD:Skt $%h File %s\r\n"
2020-06-07 08:06:51 +00:00
MSG.SKTCLOSE .AZ "HTTPD:Skt $%h Close\r\n"
*--------------------------------------
2020-06-05 19:26:34 +00:00
KEYWORDS.REQ .AS "GET "
.AS "Connection: "
.DA #0
*--------------------------------------
INDEX.HTML .AS "/index." html
*--------------------------------------
MIME.TYPES .AZ "html"
.AZ "txt"
.AZ "ttf"
.AZ "ico"
.AZ "png"
.AZ "jpg"
.DA #0
MIME.HTML .AZ "text/html"
MIME.TXT .AZ "text/plain"
MIME.TTF .AZ "font/truetype"
MIME.ICO .AZ "image/vnd.microsoft.icon" "image/x-icon"
MIME.PNG .AZ "image/png"
MIME.JPG .AZ "image/jpeg"
MIME.DEFAULT .AZ "application/octet-stream"
MIME.DEFAULT.ID .EQ 12
*--------------------------------------
HTTP.200 .AS "HTTP/1.1 200 OK"
.DA #C.CR,#C.LF
.AS "Server: A2osX-HTTPD 0.94"
.DA #C.CR,#C.LF
.AS "Content-Type: %s"
.DA #C.CR,#C.LF
.AS "Content-Length: %u"
.DA #C.CR,#C.LF
.DA #C.CR,#C.LF
.DA #0
*--------------------------------------
HTTP.404 .AS "HTTP/1.1 404 Not Found"
2019-03-04 07:14:31 +00:00
.DA #C.CR,#C.LF
2020-05-30 20:38:47 +00:00
.AS "Server: A2osX-HTTPD 0.94"
2019-03-04 07:14:31 +00:00
.DA #C.CR,#C.LF
.AS "Content-Type: text/html"
.DA #C.CR,#C.LF
2020-06-05 19:26:34 +00:00
.AS "Content-Length: 47"
2019-03-04 07:14:31 +00:00
.DA #C.CR,#C.LF
.AS "Connection: Close"
.DA #C.CR,#C.LF
.DA #C.CR,#C.LF
2020-06-05 19:26:34 +00:00
.AS "<HTML><BODY><B>404:NOT FOUND<B></BODY></HTML>"
2019-03-04 07:14:31 +00:00
.DA #C.CR,#C.LF
2020-06-05 19:26:34 +00:00
HTTP.404.len .EQ *-HTTP.404
*--------------------------------------
2019-03-02 22:18:21 +00:00
SA.LOCAL .DA #AF.INET S.SOCKADDR.AF
.BS 1
2019-03-02 22:18:21 +00:00
.BS 4 S.SOCKADDR.ADDR
.DA TCP.PORT.HTTP
*--------------------------------------
.DUMMY
.OR 0
DS.START
2020-06-05 19:26:34 +00:00
REQ.FullPath .BS MLI.MAXPATH+1
REQ.Stat .BS S.STAT
2020-06-07 08:06:51 +00:00
REQ.hReq .BS 1
2020-06-05 19:26:34 +00:00
REQ.hFile .BS 1
REQ.hBuf .BS 1
REQ.MimeType .BS 1
REQ.KeepAlive .BS 1
2020-06-07 13:47:00 +00:00
REP.hBuf .BS 1
2020-06-07 08:06:51 +00:00
CLN.hSocket .BS 1
DS.END
.ED
*--------------------------------------
MAN
2020-05-30 20:38:47 +00:00
SAVE usr/src/sbin/httpd.s
ASM