iPXE
stdio.h
Go to the documentation of this file.
00001 #ifndef _STDIO_H
00002 #define _STDIO_H
00003 
00004 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00005 
00006 #include <stdint.h>
00007 #include <stdarg.h>
00008 
00009 extern void putchar ( int character );
00010 
00011 extern int getchar ( void );
00012 
00013 extern int __attribute__ (( format ( printf, 1, 2 ) ))
00014 printf ( const char *fmt, ... );
00015 
00016 extern int __attribute__ (( format ( printf, 3, 4 ) ))
00017 snprintf ( char *buf, size_t size, const char *fmt, ... );
00018 
00019 extern int __attribute__ (( format ( printf, 2, 3 ) ))
00020 asprintf ( char **strp, const char *fmt, ... );
00021 
00022 extern int vprintf ( const char *fmt, va_list args );
00023 
00024 extern int vsnprintf ( char *buf, size_t size, const char *fmt, va_list args );
00025 
00026 extern int vasprintf ( char **strp, const char *fmt, va_list args );
00027 
00028 /**
00029  * Write a formatted string to a buffer
00030  *
00031  * @v buf               Buffer into which to write the string
00032  * @v fmt               Format string
00033  * @v ...               Arguments corresponding to the format string
00034  * @ret len             Length of formatted string
00035  */
00036 #define sprintf( buf, fmt, ... ) \
00037         snprintf ( (buf), ~( ( size_t ) 0 ), (fmt), ## __VA_ARGS__ )
00038 
00039 /**
00040  * Write a formatted string to a buffer
00041  *
00042  * @v buf               Buffer into which to write the string
00043  * @v fmt               Format string
00044  * @v args              Arguments corresponding to the format string
00045  * @ret len             Length of formatted string
00046  */
00047 static inline int vsprintf ( char *buf, const char *fmt, va_list args ) {
00048         return vsnprintf ( buf, ~( ( size_t ) 0 ), fmt, args );
00049 }
00050 
00051 #endif /* _STDIO_H */