Closed sagonzal closed 8 years ago
Hi @sagonzal, I recently (in r32), added ini_parse_stream()
to allow this kind of custom I/O. ini_parse_stream()
takes an ini_reader
function, which is basically the version of fgets
. In fact, it looks like FatFs's f_gets() has an identical signature to fgets()
, which makes it very simple.
Just define your own ini_parse_fatfs()
function and use ini_parse_stream()
, something like so (untested code):
int ini_parse_fatfs(const char* filename, ini_handler handler, void* user)
{
FRESULT result;
FIL file;
int error;
result = f_open(&file, filename, FA_OPEN_EXISTING | FA_READ);
if (result != FR_OK)
return -1;
error = ini_parse_stream((ini_reader)f_gets, &file, handler, user);
f_close(&file);
return error;
}
If the signature of the reader function differs from the standard fgets
, you have to wrap it in another function, but in this case I think you're fine.
Thank you Ben, incredible fast response!. You are absolutely right and your way does have to mess around with the code.
Great! If you create a stand-alone example that show-cases this, I'd be happy to include in the examples directory (examples/ini_fatfs.c or something). Please follow the coding style shown in examples/ini_buffer.c and examples/ini_example.c.
Sure thing. Stay tuned.
Hi @sagonzal, any update on an example that show-cases this? If not, I might close this issue for now.
Per above, closing for now. But if @sagonzal gets back with an example, happy to include it in examples/
First my gratitude for you efficient and brilliant work.
This is the results of your library, ported to an ATMEL SAM4S:
I did some, very small modifications to the function "ini_parse_file" to add support to FatFs (FAT file system module include file R0.09) in my ATMEL SAM embedded project, as you can see in the attached image:
Plus, the addition of 'ff.h' include in the top of the file. If you can I would love to help in your project but I have no idea how to add a fork in this repository. I can, of course, upload the modified file. You tell me.
Warmest regards and again, a big THANK YOU!.