aboutsummaryrefslogtreecommitdiff
path: root/src/port/snprintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/port/snprintf.c')
-rw-r--r--src/port/snprintf.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/port/snprintf.c b/src/port/snprintf.c
index 1d85c8d830e..602f7fed9c6 100644
--- a/src/port/snprintf.c
+++ b/src/port/snprintf.c
@@ -65,13 +65,19 @@
* causing nasty effects.
**************************************************************/
-/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.17 2005/03/11 17:20:35 momjian Exp $";*/
+/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.18 2005/03/11 19:13:43 momjian Exp $";*/
int pg_snprintf(char *str, size_t count, const char *fmt,...);
int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
int pg_printf(const char *format, ...);
static void dopr(char *buffer, const char *format, va_list args, char *end);
+/* Prevent recursion */
+#undef vsnprintf
+#undef snprintf
+#undef fprintf
+#undef printf
+
int
pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args)
{
@@ -97,18 +103,35 @@ pg_snprintf(char *str, size_t count, const char *fmt,...)
}
int
+pg_fprintf(FILE *stream, const char *fmt,...)
+{
+ int len;
+ va_list args;
+ char* buffer[4096];
+ char* p;
+
+ va_start(args, fmt);
+ len = pg_vsnprintf((char*)buffer, (size_t)4096, fmt, args);
+ va_end(args);
+ p = (char*)buffer;
+ for( ;*p; p++)
+ putc(*p, stream);
+ return len;
+}
+
+int
pg_printf(const char *fmt,...)
{
int len;
- va_list args;
+ va_list args;
char* buffer[4096];
- char* p;
+ char* p;
va_start(args, fmt);
len = pg_vsnprintf((char*)buffer, (size_t)4096, fmt, args);
va_end(args);
p = (char*)buffer;
- for(;*p;p++)
+ for( ;*p; p++)
putchar(*p);
return len;
}