summaryrefslogtreecommitdiff
path: root/audio/cddbd/patches/patch-ab
blob: 99b690030bbe75d474ead6e5b3dc31b9eac616e1 (plain)
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
$NetBSD: patch-ab,v 1.4 2011/08/28 22:30:17 dholland Exp $

- needs stdlib.h instead of casting return value of malloc
- other LP64 fixes
- add const to silence qsort type warnings
- fix printf follies, use stdarg.h
- don't use included custom snprintf
- avoid symbol name conflict with standard log(), which is a gcc builtin
- void main

--- cddbd.c.orig	1996-12-22 03:49:54.000000000 +0000
+++ cddbd.c
@@ -43,6 +43,8 @@ static char *_cddbd_c_ident_ = "@(#)$Id:
 #include <time.h>
 #include <sys/time.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
 #include "patchlevel.h"
 #include "access.h"
 #include "list.h"
@@ -87,7 +89,7 @@ int cddbd_locked(clck_t *);
 int cddbd_nus(int);
 int cddbd_parse_access(arg_t *, int);
 int cddbd_strcasecmp(char *, char *);
-int comp_client(void *, void *);
+int comp_client(const void *, const void *);
 int comp_user(void *, void *);
 int cvt_date(char *, char *);
 int get_conv(char **, char *);
@@ -189,18 +191,18 @@ lhead_t *lock_head;			/* Lock list head.
 
 /* Access file fields. */
 access_t acctab[] = {
-	"logfile",	logfile,       AC_PATH,    0,	     (int)TMPDIR"/log",
-	"motdfile",	motdfile,      AC_PATH,    0,	     (int)"",
-	"sitefile",	sitefile,      AC_PATH,    0,	     (int)"",
-	"histfile",	histfile,      AC_PATH,    0,	     (int)"",
-	"lockdir",	lockdir,       AC_PATH,    0,	     (int)"",
-	"hashdir",	hashdir,       AC_PATH,    0,	     (int)"",
-	"cddbdir",	cddbdir,       AC_PATH,    0,	     (int)"",
-	"dupdir",	dupdir,	       AC_PATH,    0,	     (int)"",
-	"postdir",	postdir,       AC_PATH,    0,	     (int)"",
-	"smtphost",	smtphost,      AC_STRING,  0,        (int)"localhost",
+	"logfile",	logfile,       AC_PATH,    0,	     (long)TMPDIR"/log",
+	"motdfile",	motdfile,      AC_PATH,    0,	     (long)"",
+	"sitefile",	sitefile,      AC_PATH,    0,	     (long)"",
+	"histfile",	histfile,      AC_PATH,    0,	     (long)"",
+	"lockdir",	lockdir,       AC_PATH,    0,	     (long)"",
+	"hashdir",	hashdir,       AC_PATH,    0,	     (long)"",
+	"cddbdir",	cddbdir,       AC_PATH,    0,	     (long)"",
+	"dupdir",	dupdir,	       AC_PATH,    0,	     (long)"",
+	"postdir",	postdir,       AC_PATH,    0,	     (long)"",
+	"smtphost",	smtphost,      AC_STRING,  0,        (long)"localhost",
 	"admin_email",	admin_email,   AC_STRING,  AF_NODEF, 0,
-	"bounce_email",	bounce_email,  AC_STRING,  0,	     (int)"",
+	"bounce_email",	bounce_email,  AC_STRING,  0,	     (long)"",
 	"xmit_time",	&xmit_time,    AC_NUMERIC, AF_ZERO,  DEF_XMIT_TO,
 	"transmits",	&max_xmits,    AC_NUMERIC, AF_ZERO,  DEF_MAX_XMITS,
 	"post_lines",	&max_lines,    AC_NUMERIC, AF_ZERO,  DEF_MAX_LINES,
@@ -230,7 +232,7 @@ proto_t proto_flags[MAX_PROTO_LEVEL + 1]
 
 
 /* Log flags. */
-log_t log[] = {
+static log_t logs[] = {
 	{ LOG_NONE,   0, 0,        "none",   0, },
 	{ LOG_INPUT,  0, 0,        "input",  0, },
 	{ LOG_INFO,   0, 0,        "info",   0, },
@@ -339,7 +341,7 @@ char *day[] = { "Sun", "Mon", "Tue", "We
 
 
 /* ARGSUSED */
-void
+int
 main(int argc, char **argv)
 {
 	int i;
@@ -1126,7 +1128,7 @@ cddbd_check_access(void)
 			log_flags = 0;
 
 			for(i = 1; i < args.nargs; i++) {
-				for(lp = log; lp->name; lp++) {
+				for(lp = logs; lp->name; lp++) {
 					if(!cddbd_strcasecmp(args.arg[i],
 					    lp->name)) {
 						if(lp->flag)
@@ -1460,7 +1462,7 @@ cddbd_db_init(void)
 		if(dp->d_name[0] == '.')
 			continue;
 
-		p = (char *)malloc(strlen(dp->d_name) + 1);
+		p = malloc(strlen(dp->d_name) + 1);
 		if(p == NULL) {
 			cddbd_log(LOG_ERR, "Malloc failed.");
 			quit(QUIT_ERR);
@@ -2407,8 +2409,8 @@ do_log(arg_t *args)
 		last[0] = '\0';
 	}
 
-	for(i = 0; log[i].name; i++)
-		log[i].cnt = 0;
+	for(i = 0; logs[i].name; i++)
+		logs[i].cnt = 0;
 
 	lines = 0;
 	nclient = 0; 
@@ -2452,9 +2454,9 @@ do_log(arg_t *args)
 			lines++;
 
 		/* Log the message if it's acceptable. */
-		for(i = 0; log[i].name; i++) {
-			if((log[i].flag & flag) && incl)
-				log[i].cnt++;
+		for(i = 0; logs[i].name; i++) {
+			if((logs[i].flag & flag) && incl)
+				logs[i].cnt++;
 		}
 
 		/* Count clients. */
@@ -2515,10 +2517,10 @@ do_log(arg_t *args)
 		printf("Log status between: %s and %s\r\n", start, end);
 	}
 
-	for(i = 0; log[i].name; i++)
-		if(log[i].banr != 0 && !((log[i].dflag & L_NOSHOW) &&
-		    log[i].cnt == 0))
-			printf("%s: %d\r\n", log[i].banr, log[i].cnt);
+	for(i = 0; logs[i].name; i++)
+		if(logs[i].banr != 0 && !((logs[i].dflag & L_NOSHOW) &&
+		    logs[i].cnt == 0))
+			printf("%s: %d\r\n", logs[i].banr, logs[i].cnt);
 
 	if(nclient > 0) {
 		for(i = 0; i < nclient; i++)
@@ -2541,7 +2543,7 @@ do_log(arg_t *args)
 
 	printf("Total messages: %d\r\n", lines);
 	if(sbuf.st_size != 0)
-		printf("Log size: %d bytes\r\n", sbuf.st_size);
+		printf("Log size: %lld bytes\r\n", (long long)sbuf.st_size);
 
 	printf(".\r\n");
 }
@@ -2562,15 +2564,15 @@ comp_user(void *u1, void *u2)
 
 
 int
-comp_client(void *c1, void *c2)
+comp_client(const void *c1, const void *c2)
 {
 	int x;
 
-	x = client_cnt[*(int *)c2] - client_cnt[*(int *)c1];
+	x = client_cnt[*(const int *)c2] - client_cnt[*(const int *)c1];
 	if(x != 0)
 		return(x);
 
-	return(cddbd_strcasecmp(client[*(int *)c1], client[*(int *)c2]));
+	return(cddbd_strcasecmp(client[*(const int *)c1], client[*(const int *)c2]));
 }
 
 
@@ -2895,7 +2897,7 @@ cddbd_lock_alloc(char *name)
 		quit(QUIT_ERR);
 	}
 
-	if((lk = (clck_t *)malloc(sizeof(clck_t))) == NULL) {
+	if((lk = malloc(sizeof(clck_t))) == NULL) {
 		cddbd_log(LOG_ERR | LOG_LOCK, "Can't allocate %s lock memory.",
 		    name);
 		quit(QUIT_ERR);
@@ -3179,15 +3181,15 @@ trunc_log(void)
 	}
 
 	/* Get a buffer for the file. */
-	if((buf = (char *)malloc(len)) == 0) {
+	if((buf = malloc(len)) == 0) {
 		cddbd_log(LOG_ERR, "Can't malloc %d bytes for logfile (%d).",
-		    (void *)len, errno);
+		    len, errno);
 		return;
 	}
 
 	if((fd = open(logfile, O_RDONLY)) < 0) {
 		cddbd_log(LOG_ERR, "Can't open logfile %s for reading (%d).",
-		    logfile, (void *)errno);
+		    logfile, errno);
 		free(buf);
 		return;
 	}
@@ -3195,7 +3197,7 @@ trunc_log(void)
 	/* Read in the whole log file. */
 	if(read(fd, buf, len) != len) {
 		cddbd_log(LOG_ERR, "Can't read logfile: %s (%d).", logfile,
-		    (void *)errno);
+		    errno);
 		close(fd);
 		free(buf);
 		return;
@@ -3219,7 +3221,7 @@ trunc_log(void)
 
 	if((fd = open(logfile, O_TRUNC | O_WRONLY)) < 0) {
 		cddbd_log(LOG_ERR, "Can't open logfile %s for writing (%d).",
-		    logfile, (void *)errno);
+		    logfile, errno);
 		free(buf);
 		return;
 	}
@@ -3227,7 +3229,7 @@ trunc_log(void)
 	/* Write out the truncated file. */
 	if(write(fd, p, len) != len) {
 		cddbd_log(LOG_ERR, "Can't write logfile: %s (%d).",
-		    logfile, (void *)errno);
+		    logfile, errno);
 	}
 
 	close(fd);
@@ -3236,7 +3238,7 @@ trunc_log(void)
 	return;
 }
 
-
+#if 0
 #define SCOPY(p, buf) if(cc < (CDDBBUFSIZ-1)) {(buf)[cc] = **(p),(*(p))++,cc++;}
 #define SASGN(c, buf) if(cc < (CDDBBUFSIZ-1)) {(buf)[cc] = c, cc++;}
 #define SPUT(c, buf) (buf)[cc] = c, cc++
@@ -3408,15 +3412,15 @@ cddbd_snprintf(char *buf, int size, char
 	if(!logging)
 		cddbd_log(LOG_ERR, "Buf overflow in snprintf: \"%s\"", buf);
 }
-
+#endif
 
 /* This should be the last function in the file, to avoid compile errors. */
 void
-cddbd_log(unsigned int flags, char *fmt, void *a1, void *a2, void *a3,
-    void *a4, void *a5, void *a6)
+cddbd_log(unsigned int flags, const char *fmt, ...)
 {
 	FILE *fp;
 	char buf[CDDBBUFSIZ];
+	va_list ap;
 
 	if((!(log_flags & (short)flags) && !debug) || quiet)
 		return;
@@ -3455,7 +3459,9 @@ cddbd_log(unsigned int flags, char *fmt,
 	strip_crlf(buf);
 
 	/* Print the log message. */
-	fprintf(fp, buf, a1, a2, a3, a4, a5, a6);
+	va_start(ap, fmt);
+	vfprintf(fp, buf, ap);
+	va_end(ap);
 	fputc('\n', fp);
 
 	if(fp != stderr && fp != stdout) {