1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-12 21:01:52 +03:00

Add fprintf() custom version to libpgport.

Document use of macros for pg_printf functions.

Bump major versions of all interfaces to handle movement of get_progname
from libpq to libpgport in 8.0, and probably other libpgport changes in 8.1.
This commit is contained in:
Bruce Momjian
2005-03-11 19:13:43 +00:00
parent 3bc6bdf322
commit caad817d1c
12 changed files with 65 additions and 27 deletions

View File

@ -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_printf(const char *fmt,...)
pg_fprintf(FILE *stream, 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++)
putc(*p, stream);
return len;
}
int
pg_printf(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++)
putchar(*p);
return len;
}