, FANN, , , .
, , , , , . , newlib, stdio . open(), , :
int open(const char *name, int flags, int mode) {
return -1;
}
, open , . , , :
static const char file1[] = { '\x00`, `\x01`, ... } ;
static const char file2[] = { '\x00`, `\x01`, ... } ;
static struct
{
const char* file ;
int size ;
int index ;
} files[] = { {file1, sizeof(file1), -1}, {file2, sizeof(file2), -1} } ;
open() - :
int open(const char *name, int flags, int mode)
{
static const char* file_to_handle[] = { "file1", "file2", 0 } ;
int handle = -1 ;
for( int h = 0; file_to_handle[h] != 0 && handle == -1; h++ )
{
if( strcmp( file_to_handle[h], name ) == 0 && files[h].index == -1 )
{
handle = h ;
files[h].index = 0 ;
}
}
}
read():
int read(int file, char *ptr, int len)
{
int i = -1 ;
if( files[file].index > 0 )
{
i = 0 ;
while( files[file].index < files[file].size && i < len)
{
ptr[i] = files[file].index ;
i++ ;
files[file].index++ ;
}
}
return i ;
}
close():
int close(int file)
{
files[file].index = -1 ;
return -1;
}
lseek(), FANN . files[file].index.
" " . , , , . , . , - .
newlib, , , fopen() .. .
, ROM- , , FANN.