Browse Source

Finally move the prototypes for printf() and friends to stdio.h

tags/v0.9.3
Michael Brown 17 years ago
parent
commit
06475f7b69
2 changed files with 41 additions and 34 deletions
  1. 40
    0
      src/include/stdio.h
  2. 1
    34
      src/include/vsprintf.h

+ 40
- 0
src/include/stdio.h View File

@@ -0,0 +1,40 @@
1
+#ifndef _STDIO_H
2
+#define _STDIO_H
3
+
4
+#include <stdint.h>
5
+#include <stdarg.h>
6
+
7
+extern int __attribute__ (( format ( printf, 1, 2 ) ))
8
+printf ( const char *fmt, ... );
9
+
10
+extern int __attribute__ (( format ( printf, 3, 4 ) ))
11
+snprintf ( char *buf, size_t size, const char *fmt, ... );
12
+
13
+extern int vprintf ( const char *fmt, va_list args );
14
+
15
+extern int vsnprintf ( char *buf, size_t size, const char *fmt, va_list args );
16
+
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
+/**
29
+ * Write a formatted string to a buffer
30
+ *
31
+ * @v buf		Buffer into which to write the string
32
+ * @v fmt		Format string
33
+ * @v args		Arguments corresponding to the format string
34
+ * @ret len		Length of formatted string
35
+ */
36
+static inline int vsprintf ( char *buf, const char *fmt, va_list args ) {
37
+	return vsnprintf ( buf, ~( ( size_t ) 0 ), fmt, args );
38
+}
39
+
40
+#endif /* _STDIO_H */

+ 1
- 34
src/include/vsprintf.h View File

@@ -33,8 +33,7 @@
33 33
 
34 34
 #include <stdint.h>
35 35
 #include <stdarg.h>
36
-
37
-#define PRINTF_NO_LENGTH ( ( size_t ) -1 )
36
+#include <stdio.h>
38 37
 
39 38
 /**
40 39
  * A printf context
@@ -65,36 +64,4 @@ struct printf_context {
65 64
 
66 65
 extern size_t vcprintf ( struct printf_context *ctx, const char *fmt,
67 66
 			 va_list args );
68
-extern int vsnprintf ( char *buf, size_t size, const char *fmt, va_list args );
69
-extern int vprintf ( const char *fmt, va_list args );
70
-
71
-extern int __attribute__ (( format ( printf, 3, 4 ) ))
72
-snprintf ( char *buf, size_t size, const char *fmt, ... );
73
-
74
-extern int __attribute__ (( format ( printf, 1, 2 ) ))
75
-printf ( const char *fmt, ... );
76
-
77
-/**
78
- * Write a formatted string to a buffer
79
- *
80
- * @v buf		Buffer into which to write the string
81
- * @v fmt		Format string
82
- * @v ...		Arguments corresponding to the format string
83
- * @ret len		Length of formatted string
84
- */
85
-#define sprintf( buf, fmt, ... ) \
86
-	snprintf ( (buf), PRINTF_NO_LENGTH, (fmt), ## __VA_ARGS__ )
87
-
88
-/**
89
- * Write a formatted string to a buffer
90
- *
91
- * @v buf		Buffer into which to write the string
92
- * @v fmt		Format string
93
- * @v args		Arguments corresponding to the format string
94
- * @ret len		Length of formatted string
95
- */
96
-static inline int vsprintf ( char *buf, const char *fmt, va_list args ) {
97
-	return vsnprintf ( buf, PRINTF_NO_LENGTH, fmt, args );
98
-}
99
-
100 67
 #endif /* VSPRINTF_H */

Loading…
Cancel
Save