]> git.sur5r.net Git - cc65/blobdiff - src/common/xsprintf.h
add gotox, gotoy, and gotoxy
[cc65] / src / common / xsprintf.h
index 59847a526fc85992ffa31165b2d1fb47eb9af044..07672c5c457f0b0553b53ffbc7f445174e925e9f 100644 (file)
@@ -1,15 +1,15 @@
 /*****************************************************************************/
 /*                                                                           */
-/*                               xsprintf.h                                 */
+/*                                xsprintf.h                                 */
 /*                                                                           */
-/*                      Replacement sprintf function                        */
+/*                       Replacement sprintf function                        */
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998     Ullrich von Bassewitz                                        */
-/*              Wacholderweg 14                                              */
-/*              D-70597 Stuttgart                                            */
-/* EMail:       uz@musoftware.de                                             */
+/* (C) 2000-2008 Ullrich von Bassewitz                                       */
+/*               Roemerstrasse 52                                            */
+/*               D-70794 Filderstadt                                         */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 
 
 
+/* We need a way to output a StrBuf, but on the other side, we don't want to 
+ * switch off gcc's printf format string checking. So we cheat as follows: 
+ * %m (which is a gcc extension and doesn't take an argument) switches %p 
+ * between outputting a pointer and a string buf. This works just one time,
+ * so each StrBuf needs in fact a %m%p spec. There's no way to apply a width
+ * and precision to such a StrBuf, but *not* using %p would bring up a warning
+ * about a wrong argument type each time. Maybe gcc will one day allow custom
+ * format specifiers and we can change this ...
+ */
+
+
+
 #ifndef XSPRINTF_H
 #define XSPRINTF_H
 
 
 
+#include <stdlib.h>
 #include <stdarg.h>
 
+#include "attrib.h"
+
 
 
 /*****************************************************************************/
-/*                                          Code                                    */
+/*                                   Code                                    */
 /*****************************************************************************/
 
 
 
-int xsprintf (char* Buf, size_t BufSize, const char* Format, ...);
-/* Replacement function for sprintf */
+int xvsnprintf (char* Buf, size_t Size, const char* Format, va_list ap)
+        attribute ((format (printf, 3, 0)));
+/* A basic vsnprintf implementation. Does currently only support integer
+ * formats.
+ */
+
+int xsnprintf (char* Buf, size_t Size, const char* Format, ...)
+        attribute ((format (printf, 3, 4)));
+/* A basic snprintf implementation. Does currently only support integer
+ * formats.
+ */
+
+int xsprintf (char* Buf, size_t BufSize, const char* Format, ...)
+        attribute ((format (printf, 3, 4)));
+/* Replacement function for sprintf. Will FAIL on errors. */
 
-int xvsprintf (char* Buf, size_t BufSize, const char* Format, va_list ap);
-/* Replacement function for sprintf */
+int xvsprintf (char* Buf, size_t BufSize, const char* Format, va_list ap)
+        attribute ((format (printf, 3, 0)));
+/* Replacement function for sprintf. Will FAIL on errors. */