00001
00002
00003
00004
00005
00006
00007
00008 #include "db_config.h"
00009
00010 #ifndef lint
00011 static const char revid[] = "$Id: snprintf.c,v 11.10 2002/01/11 15:51:28 bostic Exp $";
00012 #endif
00013
00014 #ifndef NO_SYSTEM_INCLUDES
00015 #include <sys/types.h>
00016
00017 #include <stdio.h>
00018 #endif
00019
00020 #include "db_int.h"
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef HAVE_SNPRINTF
00031 int
00032 #ifdef __STDC__
00033 snprintf(char *str, size_t n, const char *fmt, ...)
00034 #else
00035 snprintf(str, n, fmt, va_alist)
00036 char *str;
00037 size_t n;
00038 const char *fmt;
00039 va_dcl
00040 #endif
00041 {
00042 static int ret_charpnt = -1;
00043 va_list ap;
00044 int len;
00045
00046 COMPQUIET(n, 0);
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 if (ret_charpnt == -1) {
00057 char buf[10];
00058
00059 ret_charpnt =
00060 sprintf(buf, "123") != 3 ||
00061 sprintf(buf, "123456789") != 9 ||
00062 sprintf(buf, "1234") != 4;
00063 }
00064
00065 #ifdef __STDC__
00066 va_start(ap, fmt);
00067 #else
00068 va_start(ap);
00069 #endif
00070 len = vsprintf(str, fmt, ap);
00071 va_end(ap);
00072 return (ret_charpnt ? (int)strlen(str) : len);
00073 }
00074 #endif