kjb_vsprintf - A version of vprintf that checks for buffer overflow and has some extras
Example compile flags (system dependent):
-DLINUX_X86_64 -DLINUX_X86_64_OPTERON -DGNU_COMPILER
-lKJB -lfftw3 -lgsl -lgslcblas -ljpeg -lSVM -lstdc++ -lpthread -lSLATEC -lg2c -lacml -lacml_mv -lblas -lg2c -lncursesw
const char *format_str,
This routine is mostly use to construct others (e.g. kjb_sprintf()). However,
it may be useful outside this context, hence we export the routine.
This routine is similar to vprintf(), except that it checks for buffer
overflow. The extra formatting items described in kjb_fprintf() are
avaliable. Thus is it is more similar to vnprintf(), but that routine is not
universally available (at least at the time this routine was written).
We don't have a separate routine for when we want buffer overflow to be
checked becuase it should always be checked.
If successful, this returns the length of the printed string (not
including the null terminator character), just like vsprintf. This
returns TRUNCATED if there was not enough room in the buffer (what was
able to be written should be terminated with a NULL), and ERROR any other
a problem is encountered.
The second parameter of this routine is the size of the buffer. This is
DIFFERENT than vprintf!
We changed (back?) to returning TRUNCATED instead of calling
SET_BUFFER_OVERFLOW_BUG() in summer 2017. This routine is used in error
handling, and having to truncate is not always a bug, so calling functions
that want to treat this as a bug will have to check the return.
This software is not adequatedly tested. It is recomended that
results are checked independantly where appropriate.