Platform.icl 660 Bytes
Newer Older
Mart Lubbers's avatar
Mart Lubbers committed
1
implementation module Platform
2

Mart Lubbers's avatar
Mart Lubbers committed
3 4 5 6 7 8 9 10 11
import code from library "CleanSerial_library"

import System._Pointer
import System._WinBase

import StdMisc, StdDebug, StdBool, StdString
import Text

getDevices :: !*World -> *([String], !*World)
12
getDevices w
Mart Lubbers's avatar
Mart Lubbers committed
13 14 15 16 17 18 19
	# (ph, w) = getProcessHeap w
	# (ptr, w) = heapAlloc ph 0 40960 w
	# (ret, w) = realQDD 0 ptr 40960 w
	| ret == 0
		# (err, w) = getLastError w
		= abort ("error in QueryDosDevice: " +++ toString err)
	#! res = derefCharArray ptr ret
20
	# (ok, w) = heapFree ph 0 ptr w
Mart Lubbers's avatar
Mart Lubbers committed
21
	= (split "\0" res, w)
22

Mart Lubbers's avatar
Mart Lubbers committed
23 24 25
realQDD :: !Pointer !Pointer !Int !*env -> *(!Int, !*env)
realQDD _ _ _ _	= code {
		ccall QueryDosDeviceA@12 "PppI:I:A"
26
	}