31
31
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32
32
* SUCH DAMAGE.
33
33
*/
34
-
34
+ #if 0
35
35
# include "sendmail.h"
36
36
# 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
+
37
46
# include <sys/ioctl.h>
38
47
# include <sys/param.h>
39
48
59
68
* causing nast effects.
60
69
**************************************************************/
61
70
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 $";*/
64
72
static char * end ;
65
73
static int SnprfOverflow ;
66
74
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
+
68
79
int
69
- # ifdef __STDC__
70
80
snprintf (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
78
81
{
79
82
int len ;
80
83
VA_LOCAL_DECL
81
84
82
85
VA_START (fmt );
83
- len = vsnprintf (str , count , fmt , ap );
86
+ len = vsnprintf (str , count , fmt , args );
84
87
VA_END ;
85
88
return len ;
86
89
}
87
90
88
91
89
- # ifndef luna2
90
92
int
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 , ...)
96
94
{
95
+ VA_LOCAL_DECL
96
+
97
+ VA_START (fmt );
97
98
str [0 ] = 0 ;
98
99
end = str + count - 1 ;
99
100
SnprfOverflow = 0 ;
100
- dopr ( str , fmt , args );
101
+ dopr ( str , fmt , args );
101
102
if (count > 0 )
102
103
end [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 ;
106
108
return strlen (str );
107
109
}
108
110
@@ -117,20 +119,20 @@ static char *output;
117
119
static void dopr_outch __P (( int c ));
118
120
119
121
static void
120
- dopr ( buffer , format , args )
121
- char * buffer ;
122
- const char * format ;
123
- va_list args ;
122
+ dopr (char * buffer , const char * format , ... )
124
123
{
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 );
134
136
135
137
output = buffer ;
136
138
while ( (ch = * format ++ ) ){
@@ -143,6 +145,7 @@ dopr( buffer, format, args )
143
145
switch ( ch ){
144
146
case 0 :
145
147
dostr ( "**end of format**" , 0 );
148
+ VA_END ;
146
149
return ;
147
150
case '-' : ljust = 1 ; goto nextch ;
148
151
case '0' : /* set zero padding if len not set */
@@ -222,6 +225,7 @@ dopr( buffer, format, args )
222
225
}
223
226
}
224
227
* output = 0 ;
228
+ VA_END ;
225
229
}
226
230
227
231
static void
@@ -340,4 +344,4 @@ dopr_outch( c )
340
344
SnprfOverflow ++ ;
341
345
}
342
346
343
- # endif /* !luna2 */
347
+
0 commit comments