[Gdal-dev] RFC 7: API Change for the VSIxxxL family of file functions

Ray Gardener rayg at daylongraphics.com
Wed Nov 1 17:47:56 EST 2006

> I see. After looking at what VSIVirtualHandle provides, and what the
>  drivers in frmts and ogr need, what seems to be missing is
> equivalent functionality to fgets, fgetc, ungetc, fprintf and fscanf.
> The first three would be fairly trivial to add, but the next two ...

fprintf can be handled with:

     int our_fprintf(our_file_t stream, const char* pszFormat, ...)
         va_list argList;
         va_start(argList, pszFormat);
         int n;
             n = vfprintf(stream.filep, pszFormat, argList);
             char sz[max_printf_len + 1]; // todo: unsafe
             n = vsprintf(sz, pszFormat, argList);
             large_file_write(stream.file, sz, n);
         return n;

fscanf is admittedly non-trivial but there's open source to the rescue.
If you grab, e.g., 

it has open source implementations of CRT that you can borrow from. 
Their licence states:
"The contents of avr-libc are licensed with a Modified BSD License.
All of this is supposed to be Free Software, Open Source, DFSG-free,
GPL-compatible, and OK to use in both free and proprietary applications."


More information about the Gdal-dev mailing list