You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stdio.h 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef _STDIO_H
  2. #define _STDIO_H
  3. #include <stdint.h>
  4. #include <stdarg.h>
  5. extern int __attribute__ (( format ( printf, 1, 2 ) ))
  6. printf ( const char *fmt, ... );
  7. extern int __attribute__ (( format ( printf, 3, 4 ) ))
  8. snprintf ( char *buf, size_t size, const char *fmt, ... );
  9. extern int __attribute__ (( format ( printf, 2, 3 ) ))
  10. asprintf ( char **strp, const char *fmt, ... );
  11. extern int vprintf ( const char *fmt, va_list args );
  12. extern int vsnprintf ( char *buf, size_t size, const char *fmt, va_list args );
  13. extern int vasprintf ( char **strp, const char *fmt, va_list args );
  14. /**
  15. * Write a formatted string to a buffer
  16. *
  17. * @v buf Buffer into which to write the string
  18. * @v fmt Format string
  19. * @v ... Arguments corresponding to the format string
  20. * @ret len Length of formatted string
  21. */
  22. #define sprintf( buf, fmt, ... ) \
  23. snprintf ( (buf), ~( ( size_t ) 0 ), (fmt), ## __VA_ARGS__ )
  24. /**
  25. * Write a formatted string to a buffer
  26. *
  27. * @v buf Buffer into which to write the string
  28. * @v fmt Format string
  29. * @v args Arguments corresponding to the format string
  30. * @ret len Length of formatted string
  31. */
  32. static inline int vsprintf ( char *buf, const char *fmt, va_list args ) {
  33. return vsnprintf ( buf, ~( ( size_t ) 0 ), fmt, args );
  34. }
  35. #endif /* _STDIO_H */