-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdev_cons_open.bas
47 lines (37 loc) · 1.03 KB
/
dev_cons_open.bas
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
/' file device '/
#include "fb.bi"
dim shared as FB_FILE_HOOKS hooks_dev_cons = ( _
@fb_DevFileEof, _
@fb_DevStdIoClose, _
NULL, _
NULL, _
@fb_DevFileRead, _
@fb_DevFileReadWstr, _
@fb_DevFileWrite, _
@fb_DevFileWriteWstr, _
NULL, _
NULL, _
@fb_DevFileReadLine, _
@fb_DevFileReadLineWstr, _
NULL, _
@fb_DevFileFlush _
)
extern "C"
function fb_DevConsOpen( handle as FB_FILE ptr, filename as const ubyte ptr, filename_len as size_t ) as long
select case ( handle->mode )
case FB_FILE_MODE_APPEND, FB_FILE_MODE_INPUT, FB_FILE_MODE_OUTPUT:
'nothing
case else:
return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL )
end select
FB_LOCK()
handle->hooks = @hooks_dev_cons
if ( handle->access = FB_FILE_ACCESS_ANY) then
handle->access = FB_FILE_ACCESS_WRITE
end if
handle->opaque = iif(handle->mode = FB_FILE_MODE_INPUT, stdin, stdout)
handle->type = FB_FILE_TYPE_PIPE
FB_UNLOCK()
return fb_ErrorSetNum( FB_RTERROR_OK )
end function
end extern