File: portability_stdarg

package info (click to toggle)
ifmail 2.14tx8.10-27
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,912 kB
  • sloc: ansic: 30,327; perl: 4,955; yacc: 838; makefile: 716; sh: 424; cpp: 235; lex: 206; awk: 24
file content (143 lines) | stat: -rw-r--r-- 2,645 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
Use stdarg.h instead of varargs.h.

Bug-Debian: http://bugs.debian.org/195439

--- a/ifcico/respfreq.c
+++ b/ifcico/respfreq.c
@@ -18,7 +18,7 @@ int re_exec(char*);
 #include "lutil.h"
 #include "config.h"
 #ifndef NOFREQREPORT
-#include <varargs.h>
+#include <stdarg.h>
 #include "ftnmsg.h"
 #endif
 #include "version.h"
@@ -44,7 +44,7 @@ static file_list *resplist(char*);
 
 #ifndef NOFREQREPORT
 static void attach_report(file_list**);
-static void add_report();
+static void add_report(char*,...);
 static char *report_text=NULL;
 static unsigned long report_total=0L;
 #endif
@@ -612,15 +612,12 @@ file_list **fl;
 	report_text=NULL;
 }
 
-static void add_report(va_alist)
-va_dcl
+static void add_report(char *fmt, ...)
 {
 	va_list args;
-	char *fmt;
 	char buf[1024];
 
-	va_start(args);
-	fmt=va_arg(args,char*);
+	va_start(args,fmt);
 
 	if (report_text == NULL)
 	{
@@ -641,6 +638,7 @@ va_dcl
 	vsprintf(buf,fmt,args);
 	strcat(buf,"\r\n");
 	report_text=xstrcat(report_text,buf);
+	va_end(args);
 }
 
 #endif
--- a/iflib/lutil.c
+++ b/iflib/lutil.c
@@ -4,7 +4,7 @@
 #include <stdio.h>
 #include <sys/stat.h>
 #include <string.h>
-#include <varargs.h>
+#include <stdarg.h>
 #include <errno.h>
 #include <time.h>
 #ifdef HAS_SYSLOG
@@ -13,6 +13,8 @@
 #define LOG_USER 0
 #endif
 
+#include "xutil.h"
+
 #ifdef HAS_SYSLOG
 static int syslog_opened=0;
 #else
@@ -143,20 +145,20 @@ char c;
 		syslog(level,"\terrno=%d : %s",\
                         errno,strerror(errno));
 
-void loginf(va_alist)
-va_dcl
+void loginf(char *fmt,...)
 {
 	va_list	args;
-	char	*fmt;
 #ifndef HAS_SYSLOG
 	int	oldmask;
 #endif
 
-	va_start(args);
-	fmt=va_arg(args, char*);
+	va_start(args,fmt);
 	if (verbose)
 	{
-		PRINT_DEBUG(fmt,args);
+		va_list args2;
+		va_copy(args2, args);
+		PRINT_DEBUG(fmt,args2);
+		va_end(args2);
 	}
 #ifdef HAS_SYSLOG
 	if (!syslog_opened)
@@ -183,20 +185,20 @@ va_dcl
 	return;
 }
 
-void logerr(va_alist)
-va_dcl
+void logerr(char *fmt,...)
 {
 	va_list	args;
-	char	*fmt;
 #ifndef HAS_SYSLOG
 	int	oldmask;
 #endif
 
-	va_start(args);
-	fmt=va_arg(args, char*);
+	va_start(args,fmt);
 	if (verbose)
 	{
-		PRINT_DEBUG(fmt,args);
+		va_list args2;
+		va_copy(args2, args);
+		PRINT_DEBUG(fmt,args2);
+		va_end(args2);
 	}
 #ifdef HAS_SYSLOG
 	if (!syslog_opened)
@@ -223,16 +225,11 @@ va_dcl
 	return;
 }
 
-void debug(va_alist)
-va_dcl
+void debug(unsigned long level, char *fmt,...)
 {
 	va_list	args;
-	unsigned long	level;
-	char	*fmt;
 
-	va_start(args);
-	level=va_arg(args, unsigned long);
-	fmt=va_arg(args, char*);
+	va_start(args,fmt);
 
 	if ((verbose && (level == 0)) || (verbose & (1 << (level-1))))
 	{