browser

osdetect.xyw

osdetect.xyw
calendarsave
; .include "lib/macros.xyw"
; .include "lib/lowcase.xyw"
; .include "lib/contains.xyw"

; Pushes address to OS identifier
; -> s
.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"