emailler/test/parsequerystring.s

141 lines
2.6 KiB
ArmAsm
Raw Normal View History

.include "../inc/common.inc"
.include "../inc/commonprint.inc"
.include "../inc/net.inc"
2013-12-13 21:24:03 +00:00
.export start
.import exit_to_basic
2013-12-13 21:24:03 +00:00
.import print_a
.import get_key
.import ascii_to_native
.import http_parse_request
.import http_get_value
2014-04-28 16:41:54 +00:00
; keep LD65 happy
.segment "INIT"
.segment "ONCE"
2014-04-28 16:41:54 +00:00
.segment "STARTUP"
2013-12-13 21:24:03 +00:00
; switch to lower case charset
lda #14
jsr print_a
2013-12-13 21:24:03 +00:00
start:
jsr print_cr
2013-12-13 21:24:03 +00:00
ldax #query_1
jsr test_querystring
ldax #query_2
jsr test_querystring
2013-12-13 21:24:03 +00:00
ldax #query_3
jsr test_querystring
jsr get_key
ldax #query_4
jsr test_querystring
ldax #query_5
jsr test_querystring
2013-12-13 21:24:03 +00:00
ldax #query_6
jsr test_querystring
jmp exit_to_basic
2013-12-13 21:24:03 +00:00
test_querystring:
stax temp_ax
2013-12-13 21:24:03 +00:00
jsr print_ascii_as_native
jsr print_cr
ldax temp_ax
2013-12-13 21:24:03 +00:00
jsr http_parse_request
2013-12-13 21:24:03 +00:00
lda #1
jsr print_var
lda #2
jsr print_var
lda #'h'
jsr print_var
lda #'m'
jsr print_var
lda #'q'
jsr print_var
2013-12-13 21:24:03 +00:00
rts
print_var:
pha
cmp #1
beq @print_method
cmp #2
2013-12-13 21:24:03 +00:00
beq @print_path
jsr ascii_to_native
jsr print_a
@print_equals:
lda #'='
jsr print_a
pla
jsr http_get_value
bcc @found_var_value
lda #'?'
jsr print_a
jmp print_cr
@found_var_value:
2013-12-13 21:24:03 +00:00
jsr print_ascii_as_native
jmp print_cr
2013-12-13 21:24:03 +00:00
@print_path:
ldax #path
jmp @print_caption
@print_method:
ldax #method
@print_caption:
jsr print_ascii_as_native
jmp @print_equals
.bss
temp_ax: .res 2
.rodata
path:
.byte "path",0
method:
.byte "method",0
2013-12-13 21:24:03 +00:00
query_1:
.byte "GET /?h=slack&m=goober+woober+woo%21+%3B+i+am+text HTTP/1.1",0
query_2:
.byte "POST /?h=slack&m=goober+woober+woo!+%3b+i+am+text",0
query_3:
.byte "GET /?handle=slack&message=goober+woober+woo%21+%3B+i+am+text+%0d%0a%21%40%23%24%25%5E%26%25%5D%5B%7B%7D& HTTP/1.1",0
query_4:
.byte "GET /this/is/a/long/q/path.html?q=foo",0
query_5:
.byte "/this/is/a/gopher_selector",0
query_6:
.byte $0d,$0a,0 ; this should also be a gopher path
2013-12-13 21:24:03 +00:00
2014-04-13 16:36:04 +00:00
; -- LICENSE FOR parsequerystring.s --
2013-12-13 21:24:03 +00:00
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
2013-12-13 21:24:03 +00:00
; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations
; under the License.
;
2013-12-13 21:24:03 +00:00
; The Original Code is ip65.
;
2013-12-13 21:24:03 +00:00
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2009
; Jonno Downes. All Rights Reserved.
2013-12-13 21:24:03 +00:00
; -- LICENSE END --