Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

stdio.h 1.4KB

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