Back to index

citadel  8.12
Functions
snprintf.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int snprintf (char *buf, size_t max, const char *fmt,...)
int vsnprintf (char *buf, size_t max, const char *fmt, va_list argp)

Function Documentation

int snprintf ( char *  buf,
size_t  max,
const char *  fmt,
  ... 
)

Definition at line 69 of file snprintf.c.

{
  va_list argp;
  int bytes;

  va_start(argp, fmt);
  bytes = vsnprintf(buf, max, fmt, argp);
  va_end(argp);

  return bytes;
}

Here is the call graph for this function:

int vsnprintf ( char *  buf,
size_t  max,
const char *  fmt,
va_list  argp 
)

Definition at line 48 of file snprintf.c.

{
  char *p;
  int size;

  if ((p = malloc(needed(fmt, argp) + 1)) == NULL)
    {
      fprintf(stderr, "vsnprintf: malloc failed, aborting\n");
      abort();
    }

  if ((size = vsprintf(p, fmt, argp)) >= max)
    size = -1;

  strncpy(buf, p, max);
  buf[max - 1] = 0;
  free(p);
  return size;
}

Here is the call graph for this function:

Here is the caller graph for this function: