FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
file_getstr.c
Go to the documentation of this file.
1
/* get # function for strings */
2
3
#include "
fb.h
"
4
5
int
fb_FileGetStrEx
(
FB_FILE
*
handle
,
fb_off_t
pos,
void
*str, ssize_t str_len,
size_t
*bytesread )
6
{
7
int
res;
8
size_t
len;
9
char
*data;
10
11
if
( bytesread )
12
*bytesread = 0;
13
14
if
( !
FB_HANDLE_USED
(handle) )
15
return
fb_ErrorSetNum
(
FB_RTERROR_ILLEGALFUNCTIONCALL
);
16
17
/* get string len */
18
FB_STRSETUP_DYN
( str, str_len, data, len );
19
20
/* perform call ... but only if there's data ... */
21
if
( (data !=
NULL
) && (len > 0) ) {
22
res =
fb_FileGetDataEx
( handle, pos, data, len, &len,
TRUE
,
FALSE
);
23
data[len] = 0;
/* add the null-term */
24
}
else
{
25
res =
fb_ErrorSetNum
(
FB_RTERROR_ILLEGALFUNCTIONCALL
);
26
}
27
28
if
( bytesread )
29
*bytesread = len;
30
31
/* del if temp */
32
if
( str_len == -1 )
33
fb_hStrDelTemp
( (
FBSTRING
*)str );
/* will free the temp desc if fix-len passed */
34
35
return
res;
36
}
37
38
FBCALL
int
fb_FileGetStr
(
int
fnum,
int
pos,
void
*str, ssize_t str_len )
39
{
40
return
fb_FileGetStrEx
(
FB_FILE_TO_HANDLE
(fnum), pos, str, str_len,
NULL
);
41
}
42
43
FBCALL
int
fb_FileGetStrLarge
(
int
fnum,
long
long
pos,
void
*str, ssize_t str_len )
44
{
45
return
fb_FileGetStrEx
(
FB_FILE_TO_HANDLE
(fnum), pos, str, str_len,
NULL
);
46
}
47
48
FBCALL
int
fb_FileGetStrIOB
(
int
fnum,
int
pos,
void
*str, ssize_t str_len,
size_t
*bytesread )
49
{
50
return
fb_FileGetStrEx
(
FB_FILE_TO_HANDLE
(fnum), pos, str, str_len, bytesread);
51
}
52
53
FBCALL
int
fb_FileGetStrLargeIOB
(
int
fnum,
long
long
pos,
void
*str, ssize_t str_len,
size_t
*bytesread )
54
{
55
return
fb_FileGetStrEx
(
FB_FILE_TO_HANDLE
(fnum), pos, str, str_len, bytesread);
56
}
rtlib
file_getstr.c
Generated on Thu Jan 23 2014 19:40:11 for FreeBASIC by
1.8.4