FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
file_winputstr.c
Go to the documentation of this file.
1
/* winput$ function */
2
3
#include "
fb.h
"
4
5
FBCALL
FB_WCHAR
*
fb_FileWstrInput
( ssize_t chars,
int
fnum )
6
{
7
FB_FILE
*
handle
;
8
FB_WCHAR
*dst;
9
size_t
len;
10
int
res =
FB_RTERROR_OK
;
11
12
fb_DevScrnInit_ReadWstr
( );
13
14
FB_LOCK
();
15
16
handle =
FB_FILE_TO_HANDLE
(fnum);
17
if
( !
FB_HANDLE_USED
(handle) )
18
{
19
FB_UNLOCK
();
20
return
NULL
;
21
}
22
23
dst =
fb_wstr_AllocTemp
( chars );
24
if
( dst !=
NULL
)
25
{
26
size_t
read_chars = 0;
27
if
(
FB_HANDLE_IS_SCREEN
(handle) )
28
{
29
while
( read_chars != chars )
30
{
31
res =
fb_FileGetDataEx
( handle,
32
0,
33
(
void
*)&dst[read_chars],
34
chars - read_chars,
35
&len,
36
TRUE
,
37
TRUE
);
38
if
( res !=
FB_RTERROR_OK
)
39
break
;
40
41
read_chars += len;
42
}
43
}
44
else
45
{
46
res =
fb_FileGetDataEx
( handle,
47
0,
48
(
void
*)dst,
49
chars,
50
&len,
51
TRUE
,
52
TRUE
);
53
read_chars = chars;
54
}
55
56
if
( res ==
FB_RTERROR_OK
)
57
{
58
dst[read_chars] =
_LC
(
'\0'
);
59
}
60
else
61
{
62
fb_wstr_Del
( dst );
63
dst =
NULL
;
64
}
65
66
}
67
else
68
res =
FB_RTERROR_OUTOFMEM
;
69
70
FB_UNLOCK
();
71
72
return
dst;
73
}
rtlib
file_winputstr.c
Generated on Thu Jan 23 2014 19:40:11 for FreeBASIC by
1.8.4