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

3
import code from library "CleanSerial_library"
4
import code from library "CleanSerial2_library"
5 6 7 8 9 10 11 12

import System._Pointer
import System._WinBase

import StdMisc, StdDebug, StdBool, StdString
import Text

getDevices :: !*World -> *([String], !*World)
13
getDevices w
14 15 16 17 18 19 20
	# (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
21
	# (ok, w) = heapFree ph 0 ptr w
22
	= (split "\0" res, w)
23

24 25 26
realQDD :: !Pointer !Pointer !Int !*env -> *(!Int, !*env)
realQDD _ _ _ _	= code {
		ccall QueryDosDeviceA@12 "PppI:I:A"
27
	}