examples/lib/osdetect.xyw
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
; UNTESTED
; .include "lib/macros.xyw"
; .include "lib/lowcase.xyw"
; .include "lib/contains.xyw"
; Pushes address to OS identifier
; -- a16
.label osdetect
; Set command to execute
osdetect.cmd file.path STW
; Capture output to buffer
osdetect.output file.read STW
$0040 file.length STW
; Execute command
file.op.exec file.operation STB
; Convert to lowercase
osdetect.output lowcase JSRw
; Write OS identifier to address
osdetect.output osdetect.linux contains JSRw
osdetect.res.linux JCNw
osdetect.output osdetect.mingw contains JSRw
osdetect.res.windows JCNw
osdetect.output osdetect.windows contains JSRw
osdetect.res.windows JCNw
osdetect.output osdetect.darwin contains JSRw
osdetect.res.macos JCNw
osdetect.output osdetect.bsd contains JSRw
osdetect.res.bsd JCNw
; Unknown OS
osdetect.unknown RTS
; results
.label osdetect.res.linux
osdetect.linux RTS
.label osdetect.res.windows
osdetect.windows RTS
.label osdetect.res.macos
osdetect.macos RTS
.label osdetect.res.bsd
osdetect.bsd RTS
; strings
.label osdetect.output
.reserve $0040
.label osdetect.cmd
.string "uname -s"
.label osdetect.linux
.string "linux"
.label osdetect.bsd
.string "bsd"
.label osdetect.darwin
.string "darwin"
.label osdetect.mingw
.string "mingw"
.label osdetect.windows
.string "windows"
.label osdetect.macos
.string "macos"
.label osdetect.unknown
.string "unknown"
|