We are looking for the source code for snprintf ()

I need to port snprintf () to another platform that does not fully support GLibC.

I am looking for a basic declaration in Glibc 2.14 source code. I make many function calls, but get stuck in vfprintf (). Then it calls _IO_vfprintf (), but I can not find the definition. The macro is probably confusing things.

I need to see a real C code that scans a format string and calculates the number of bytes that it would write if the input buffer was large enough.

I also tried searching in newlib 1.19.0, but I was stuck on _svfprintf_r (). I cannot find a definition anywhere.

Can someone give me a definition or something else for snprintf ()?

+3
source share
3 answers

http://www.ijs.si/software/snprintf/ , , snprintf, vsnprintf.c, asnprintf, vasnprintf, asprintf, vasprintf. , .

+4

, _svfprintf_r() ( ) Newlib. , , . Newlib 1.20.0 , , .

vfprintf.c. _VFPRINTF_R, _svfiprintf_r, _vfiprintf_r, _svfprintf_r _VFPRINTF_R ( ), :

int
_DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap),
       struct _reent *data _AND
       FILE * fp           _AND
       _CONST char *fmt0   _AND
       va_list ap)
{
    ...
+5

The source code for the GNU C library (glibc) is hosted on sourceware.org .

Here is a link to the implementation vfprintf()that is being called snprintf(): https://sourceware.org/git/?p=glibc.git;a=blob;f=stdio-common/vfprintf.c

+5
source

All Articles