FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
dev_file_encod_read.c
Go to the documentation of this file.
1
/* UTF-encoded input for file devices */
2
3
#include "
fb.h
"
4
5
int
fb_DevFileReadEncod
(
FB_FILE
*
handle
,
void
*dst,
size_t
*max_chars )
6
{
7
FILE *fp;
8
size_t
chars;
9
10
FB_LOCK
();
11
12
chars = *max_chars;
13
14
fp = (FILE *)handle->
opaque
;
15
if
( fp == stdout || fp == stderr )
16
fp = stdin;
17
18
if
( fp ==
NULL
)
19
{
20
FB_UNLOCK
();
21
return
fb_ErrorSetNum
(
FB_RTERROR_ILLEGALFUNCTIONCALL
);
22
}
23
24
/* do read */
25
chars =
fb_hFileRead_UTFToChar
( fp, handle->
encod
, dst, chars );
26
27
/* fill with nulls if at eof */
28
if
( chars != *max_chars )
29
memset( ((
char
*)dst) + chars, 0, *max_chars - chars );
30
31
*max_chars = chars;
32
33
FB_UNLOCK
();
34
35
return
fb_ErrorSetNum
(
FB_RTERROR_OK
);
36
}
rtlib
dev_file_encod_read.c
Generated on Thu Jan 23 2014 19:40:08 for FreeBASIC by
1.8.4