3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
3333 */
34-
34+ #if 0
3535# include "sendmail.h"
3636# include "pathnames.h"
37+ #endif
38+
39+ # include "postgres.h"
40+
41+ # include <stdarg.h>
42+ # define VA_LOCAL_DECL va_list args;
43+ # define VA_START (f ) va_start(args, f)
44+ # define VA_END va_end(args)
45+
3746# include <sys/ioctl.h>
3847# include <sys/param.h>
3948
5968 * causing nast effects.
6069 **************************************************************/
6170
62- /*static char _id[] = "$Id: snprintf.c,v 1.4 1998/09/04 14:34:23 scrappy Exp $";*/
63- static void dopr ();
71+ /*static char _id[] = "$Id: snprintf.c,v 1.5 1998/09/10 04:11:52 vadim Exp $";*/
6472static char * end ;
6573static int SnprfOverflow ;
6674
67- /* VARARGS3 */
75+ int snprintf (char * str ,size_t count ,const char * fmt , ...);
76+ int vsnprintf (char * str ,size_t count ,const char * fmt , ...);
77+ static void dopr (char * buffer ,const char * format , ... );
78+
6879int
69- # ifdef __STDC__
7080snprintf (char * str ,size_t count ,const char * fmt , ...)
71- # else
72- snprintf (str ,count ,fmt ,va_alist )
73- char * str ;
74- size_t count ;
75- const char * fmt ;
76- va_dcl
77- #endif
7881{
7982int len ;
8083VA_LOCAL_DECL
8184
8285VA_START (fmt );
83- len = vsnprintf (str ,count ,fmt ,ap );
86+ len = vsnprintf (str ,count ,fmt ,args );
8487VA_END ;
8588return len ;
8689}
8790
8891
89- # ifndef luna2
9092int
91- vsnprintf (str ,count ,fmt ,args )
92- char * str ;
93- size_t count ;
94- const char * fmt ;
95- va_list args ;
93+ vsnprintf (char * str ,size_t count ,const char * fmt , ...)
9694{
95+ VA_LOCAL_DECL
96+
97+ VA_START (fmt );
9798str [0 ]= 0 ;
9899end = str + count - 1 ;
99100SnprfOverflow = 0 ;
100- dopr (str ,fmt ,args );
101+ dopr (str ,fmt ,args );
101102if (count > 0 )
102103end [0 ]= 0 ;
103- if (SnprfOverflow && tTd (57 ,2 ))
104- printf ("\nvsnprintf overflow, len = %d, str = %s" ,
105- count ,shortenstring (str ,203 ));
104+ if (SnprfOverflow )
105+ elog (NOTICE ,"vsnprintf overflow, len = %d, str = %s" ,
106+ count ,str );
107+ VA_END ;
106108return strlen (str );
107109}
108110
@@ -117,20 +119,20 @@ static char *output;
117119static void dopr_outch __P ((int c ));
118120
119121static void
120- dopr (buffer ,format ,args )
121- char * buffer ;
122- const char * format ;
123- va_list args ;
122+ dopr (char * buffer ,const char * format , ... )
124123{
125- int ch ;
126- long value ;
127- int longflag = 0 ;
128- int pointflag = 0 ;
129- int maxwidth = 0 ;
130- char * strvalue ;
131- int ljust ;
132- int len ;
133- int zpad ;
124+ int ch ;
125+ long value ;
126+ int longflag = 0 ;
127+ int pointflag = 0 ;
128+ int maxwidth = 0 ;
129+ char * strvalue ;
130+ int ljust ;
131+ int len ;
132+ int zpad ;
133+ VA_LOCAL_DECL
134+
135+ VA_START (format );
134136
135137output = buffer ;
136138while ( (ch = * format ++ ) ){
@@ -143,6 +145,7 @@ dopr( buffer, format, args )
143145switch (ch ){
144146case 0 :
145147dostr ("**end of format**" ,0 );
148+ VA_END ;
146149return ;
147150case '-' :ljust = 1 ; gotonextch ;
148151case '0' :/* set zero padding if len not set */
@@ -222,6 +225,7 @@ dopr( buffer, format, args )
222225 }
223226 }
224227* output = 0 ;
228+ VA_END ;
225229}
226230
227231static void
@@ -340,4 +344,4 @@ dopr_outch( c )
340344SnprfOverflow ++ ;
341345}
342346
343- # endif /* !luna2 */
347+