MCPcopy Create free account
hub / github.com/OpenPrinting/cups / _cups_safe_vsnprintf

Function _cups_safe_vsnprintf

cups/debug.c:354–667  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

352 */
353
354ssize_t /* O - Number of bytes formatted */
355_cups_safe_vsnprintf(
356 char *buffer, /* O - Output buffer */
357 size_t bufsize, /* O - Size of output buffer */
358 const char *format, /* I - printf-style format string */
359 va_list ap) /* I - Pointer to additional arguments */
360{
361 char *bufptr, /* Pointer to position in buffer */
362 *bufend, /* Pointer to end of buffer */
363 size, /* Size character (h, l, L) */
364 type; /* Format type character */
365 int width, /* Width of field */
366 prec; /* Number of characters of precision */
367 char tformat[100], /* Temporary format string for snprintf() */
368 *tptr, /* Pointer into temporary format */
369 temp[1024]; /* Buffer for formatted numbers */
370 char *s; /* Pointer to string */
371 ssize_t bytes; /* Total number of bytes needed */
372
373
374 if (!buffer || bufsize < 2 || !format)
375 return (-1);
376
377 /*
378 * Loop through the format string, formatting as needed...
379 */
380
381 bufptr = buffer;
382 bufend = buffer + bufsize - 1;
383 bytes = 0;
384
385 while (*format)
386 {
387 if (*format == '%')
388 {
389 tptr = tformat;
390 *tptr++ = *format++;
391
392 if (*format == '%')
393 {
394 if (bufptr < bufend)
395 *bufptr++ = *format;
396 bytes ++;
397 format ++;
398 continue;
399 }
400 else if (strchr(" -+#\'", *format))
401 *tptr++ = *format++;
402
403 if (*format == '*')
404 {
405 /*
406 * Get width from argument...
407 */
408
409 format ++;
410 width = va_arg(ap, int);
411

Callers 2

format_log_lineFunction · 0.85
_cups_debug_printfFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected