deps/kb_meme/meme-5.0.1/src/buffer.c
/*
 * buf_printf
 * prints the format to the buffer
 * returns the 0 on success or the number of bytes needed
 * on failure
 */
buf_printf
prints the format to the buffer
returns the 0 on success or the number of bytes needed
on failure
buf_printf prints the format to the buffer returns the 0 on success or the number of bytes needed on failure
int buf_printf(BUF_T *buf, const char *fmt, ...) {
  int remaining, rvalue;
  char *dest;
  va_list args;
  remaining = buf->limit - buf->position;
  dest = (buf->buffer)+(buf->position);
  va_start(args, fmt);
  rvalue = vsnprintf(dest, remaining*sizeof(char), fmt, args);
  va_end(args);
  if (rvalue <= remaining) {
    buf->position += rvalue; 
    return 0;
  } else {
    return rvalue - remaining;
  }
}
int buf_printf ( BUF_T * buf , const char * fmt , ... ) { int remaining , rvalue ; char * dest ; va_list args ; remaining = buf -> limit - buf -> position ; dest = ( buf -> buffer ) + ( buf -> position ) ; va_start ( args , fmt ) ; rvalue = vsnprintf ( dest , remaining * sizeof ( char ) , fmt , args ) ; va_end ( args ) ; if ( rvalue <= remaining ) { buf -> position += rvalue ; return 0 ; } else { return rvalue - remaining ; } }
buf_printf
 prints the format to the buffer
 returns the 0 on success or the number of bytes needed
 on failure
buf_printf prints the format to the buffer returns the 0 on success or the number of bytes needed on failure
//note that \0 byte is not included in rvalue //hence it will be overwritten in the next call //return the number of bytes needed