vsprintf.c 575 B

1234567891011121314151617181920212223242526
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <sys/types.h>
  3. #include <linux/kernel.h>
  4. #include <stdio.h>
  5. int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
  6. {
  7. int i = vsnprintf(buf, size, fmt, args);
  8. ssize_t ssize = size;
  9. return (i >= ssize) ? (ssize - 1) : i;
  10. }
  11. int scnprintf(char * buf, size_t size, const char * fmt, ...)
  12. {
  13. ssize_t ssize = size;
  14. va_list args;
  15. int i;
  16. va_start(args, fmt);
  17. i = vsnprintf(buf, size, fmt, args);
  18. va_end(args);
  19. return (i >= ssize) ? (ssize - 1) : i;
  20. }