NAME

kjb_vsprintf - A version of vprintf that checks for buffer overflow and has some extras

SYNOPSIS

#include "l/l_sys_str.h"

Example compile flags (system dependent):
  -DLINUX_X86_64 -DLINUX_X86_64_OPTERON  -DGNU_COMPILER 
   -I/home/kobus/include
   -L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
  -lKJB                               -lfftw3  -lgsl -lgslcblas -ljpeg  -lSVM -lstdc++                    -lpthread -lSLATEC -lg2c    -lacml -lacml_mv -lblas -lg2c      -lncursesw 


long kjb_vsprintf
(
	char *buff,
	size_t max_len,
	const char *format_str,
	va_list ap
);

DESCRIPTION

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.

RETURNS

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.

WARNING

The second parameter of this routine is the size of the buffer. This is DIFFERENT than vprintf!

NOTE

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.

RELATED

kjb_fprintf, kjb_sprintf

DISCLAIMER

This software is not adequatedly tested. It is recomended that results are checked independantly where appropriate.

AUTHOR

Kobus Barnard

DOCUMENTER

Kobus Barnard

SEE ALSO

kjb_sprintf