let IO := requireModule "IO" in let FFI := requireModule "FFI" in let List := requireModule "List" in let nil? := List.nil? in let Logic := requireModule "Logic" in let Arithmetic := requireModule "Arithmetic" in let Composition := requireModule "Composition" in let rem := Composition.rem in let ($) := Composition.($) in let String := requireModule "String" in let PATHMAX := Builtins.PATHMAX in let return! := IO.liftIO! in let (;) := IO.(;) in let packRecord := FFI.packRecord in let unpackRecord := FFI.unpackRecord in let duplicateRecord! := FFI.duplicateRecord! in let allocateRecord! := FFI.allocateRecord! in let allocateMemory! := FFI.allocateMemory! in let strUntilZero := FFI.strUntilZero in let substr := FFI.substr in let requireSharedLibrary := FFI.requireSharedLibrary in let map := List.map in let if := Logic.if in let else := Logic.else in let elif := Logic.elif in let (=) := Arithmetic.(=) in let (+) := Arithmetic.(+) in let (-) := Arithmetic.(-) in let structTmFormat := "iiiiiiiii" in let timeTFormat := "L" in rem "This is mostly copied from POSIX - as it seems Microsoft did that, too - although the threadsafe _r functions are missing." let time! := (requireSharedLibrary filename 'CiP "time" []) in let localtimeR! := (\time let timeBox := packRecord timeTFormat [time] in requireSharedLibrary filename 'CPp "localtime" timeBox ;\tm return! (unpackRecord structTmFormat tm) ) in let localtime! := localtimeR! in let gmtimeR! := (\time let timeBox := packRecord timeTFormat [time] in requireSharedLibrary filename 'CPp "gmtime" timeBox ;\tm return! (unpackRecord structTmFormat tm) ) in let gmtime! := gmtimeR! in export let timegm! := (\tm rem "MSVC likes to change the input structure contents" duplicateRecord! (packRecord structTmFormat tm) ;\dtm Builtins.mkgmtime! dtm ) in export let mkgmtime! := timegm! in export let mktime! := (\tm rem "MSVC likes to change the input structure contents" duplicateRecord! (packRecord structTmFormat tm) ;\dtm Builtins.mktime! dtm ) in let strftime! := (\format \tm duplicateRecord! "0123456789012345678901234567890" ;\buffer let tmBox := (packRecord structTmFormat tm) in requireSharedLibrary filename 'Clplpp "strftime" buffer 30 format tmBox ;\rc return! (if (rc = 0) [] $else (substr buffer 0 rc)) ) in let execv! := (\progName \args requireSharedLibrary filename 'Cipp "_execv" progName (packRecord "[p]P" [(map (\i [i]) args) []]) ) in let execve! := (\progName \args \env requireSharedLibrary filename 'Cippp "_execve" progName (packRecord "[p]P" [(map (\i [i]) args) []]) (packRecord "[p]P" [(map (\i [i]) env) []]) ) in let execvp! := (\progName \args requireSharedLibrary filename 'Cipp "_execvp" progName (packRecord "[p]P" [(map (\i [i]) args) []]) ) in let execvpe! := (\progName \args \env requireSharedLibrary filename 'Cippp "_execvpe" progName (packRecord "[p]P" [(map (\i [i]) args) []]) (packRecord "[p]P" [(map (\i [i]) env) []]) ) in