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

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