forked from ImortisInglorian/fbrtLib
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdev_scrn.bas
63 lines (53 loc) · 1.77 KB
/
dev_scrn.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/' file device '/
#include "fb.bi"
extern "C"
dim shared as FB_FILE_HOOKS hooks_dev_scrn = ( _
@fb_DevScrnEof, _
@fb_DevScrnClose, _
NULL, _
NULL, _
@fb_DevScrnRead, _
@fb_DevScrnReadWstr, _
@fb_DevScrnWrite, _
@fb_DevScrnWriteWstr, _
NULL, _
NULL, _
@fb_DevScrnReadLine, _
@fb_DevScrnReadLineWstr, _
NULL, _
NULL )
function fb_DevScrnOpen( handle as FB_FILE ptr, filename as ubyte const ptr, filename_len as size_t ) as long
FB_LOCK()
if (handle <> @FB_HANDLE_SCREEN) then
/' Duplicate and copy the DEV_SCRN_INFO from FB_HANDLE_SCREEN '/
dim as DEV_SCRN_INFO ptr _screeninfo = cast(DEV_SCRN_INFO ptr, FB_HANDLE_SCREEN.opaque)
dim as DEV_SCRN_INFO ptr info = malloc(sizeof(DEV_SCRN_INFO))
memcpy(info, _screeninfo, sizeof(DEV_SCRN_INFO))
handle->opaque = info
handle->hooks = @hooks_dev_scrn
handle->redirection_to = @FB_HANDLE_SCREEN
elseif ( handle->hooks <> @hooks_dev_scrn ) then
if ( handle->hooks = NULL ) then
fb_DevScrnInit_Screen( )
end if
handle->hooks = @hooks_dev_scrn
handle->type = FB_FILE_TYPE_CONSOLE
end if
FB_UNLOCK()
return fb_ErrorSetNum( FB_RTERROR_OK )
end function
sub fb_DevScrnInit( )
FB_LOCK( )
if ( FB_HANDLE_SCREEN.hooks = NULL ) then
memset(@FB_HANDLE_SCREEN, 0, sizeof(FB_HANDLE_SCREEN))
FB_HANDLE_SCREEN.mode = FB_FILE_MODE_APPEND
FB_HANDLE_SCREEN.encod = FB_FILE_ENCOD_DEFAULT
FB_HANDLE_SCREEN.type = FB_FILE_TYPE_VFS
FB_HANDLE_SCREEN.access = FB_FILE_ACCESS_READWRITE
fb_DevScrnOpen( @FB_HANDLE_SCREEN, NULL, 0 )
elseif ( FB_HANDLE_SCREEN.hooks <> @hooks_dev_scrn ) then
FB_HANDLE_SCREEN.hooks = @hooks_dev_scrn
end if
FB_UNLOCK( )
end sub
end extern