File: 02-warnings

package info (click to toggle)
jesred 1.2pl1-23
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, trixie
  • size: 588 kB
  • sloc: ansic: 1,359; makefile: 76
file content (289 lines) | stat: -rw-r--r-- 9,365 bytes parent folder | download | duplicates (4)
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
Author: Alexander Zangerl <az@debian.org>
Subject: fix warnings

--- a/config.c
+++ b/config.c
@@ -58,13 +58,13 @@ read_allow(char **file, ip_acl **list) {
     fd = fopen(*file, "r");
     if(fd == NULL) {
 	token = strerror(errno);
-	log(ERROR, "unable to open local addresses file %s: %s\n",
+	mylog(ERROR, "unable to open local addresses file %s: %s\n",
 	    *file ? *file : "", token);
 	echo_mode = 1;
 	return;
     }
     
-    log(INFO, "Loading IP List from %s\n",*file);
+    mylog(INFO, "Loading IP List from %s\n",*file);
     while( !echo_mode && (fgets(buff, BUFSIZE, fd) != NULL) ) {
 	token = CleanLine(buff);
 	if ( token == NULL )
@@ -177,11 +177,11 @@ read_rules(char **file, pattern_item **p
     if ( ! *file || (fd = fopen(*file, "rt")) == NULL ) {
 	echo_mode = 1;
 	token = strerror(errno);
-	log(ERROR, "unable to open redirect patterns file %s: %s\n",
+	mylog(ERROR, "unable to open redirect patterns file %s: %s\n",
 	    *file ? *file : "", token);
 	return;
     }
-    log(INFO, "Reading Patterns from config %s\n", *file);
+    mylog(INFO, "Reading Patterns from config %s\n", *file);
     
     while(!echo_mode && (fgets(buff, BUFSIZE, fd) != NULL)) {
 	
--- a/ip_list.c
+++ b/ip_list.c
@@ -136,17 +136,17 @@ ip_access_check(struct in_addr address,
 
 #ifdef DEBUG
     if (!list) {
-	log(DEBG, "ACL: denied %s\n", inet_ntoa(address));
+	mylog(DEBG, "ACL: denied %s\n", inet_ntoa(address));
 	return IP_DENY;
     }
     for (p = list; p; p = p->next) {
 	if (ip_acl_match(address, p)) {
-	    log(DEBG, "ACL: %s %s\n", p->access==IP_DENY ? "denied" : "allowed",
+	    mylog(DEBG, "ACL: %s %s\n", p->access==IP_DENY ? "denied" : "allowed",
 		inet_ntoa(address));
 	    return p->access;
 	}
     }
-    log(DEBG, "ACL: denied %s\n", inet_ntoa(address));
+    mylog(DEBG, "ACL: denied %s\n", inet_ntoa(address));
     return IP_DENY;
 #else
     if (!list)
@@ -194,7 +194,7 @@ addToIPACL(ip_acl **list, const char *ip
     a1 = a2 = a3 = a4 = 0;
     c = sscanf(ip_str, "%d.%d.%d.%d/%d", &a1, &a2, &a3, &a4, &m1);
     if (m1 < 0 || m1 > 32) {
-	log(ERROR, "addToIPACL: Ignoring invalid IP acl line '%s'\n",
+	mylog(ERROR, "addToIPACL: Ignoring invalid IP acl line '%s'\n",
 	      ip_str);
 	return;
     }
--- a/log.c
+++ b/log.c
@@ -63,7 +63,7 @@ openFile(char *file)
 }
 
 void
-log(log_code c, char *format, ...) {
+mylog(log_code c, char *format, ...) {
     FILE *fd;
     
     char msg[BUFSIZE];
--- a/log.h
+++ b/log.h
@@ -30,7 +30,7 @@ typedef enum {
     INFO
 } log_code;
 
-extern void log(log_code c, char *format, ...);
+extern void mylog(log_code c, char *format, ...);
 extern void closeLogs(void);
 extern void openLogs(char **, char **);
 
--- a/main.c
+++ b/main.c
@@ -96,7 +96,7 @@ int main(int argc, char **argv)
 	int val;
 	
 	sig_hup = 0;
-	log(INFO, "Freeing up old linked lists\n");
+	mylog(INFO, "Freeing up old linked lists\n");
 	ip_acl_destroy(&ip_list);
 	plist_destroy(&pattern_list);
 	closeLogs();
@@ -107,8 +107,8 @@ int main(int argc, char **argv)
 	read_rules(&f_rules, &pattern_list);
 	
 	if(echo_mode)
-	    log(ERROR, "Invalid condition - continuing in ECHO mode\n");
-	log(INFO, "%s (PID %d) started\n", APPNAME, (int)getpid());
+	    mylog(ERROR, "Invalid condition - continuing in ECHO mode\n");
+	mylog(INFO, "%s (PID %d) started\n", APPNAME, (int)getpid());
 	
 	while((!sig_hup) && (fgets(buff, BUFSIZE, stdin) != NULL)){
 	    if(echo_mode) {
@@ -129,7 +129,7 @@ int main(int argc, char **argv)
 	    if(echo_mode) {
 		puts("");
 		fflush(stdout);
-		log(ERROR, "Invalid condition - continuing in ECHO mode\n");
+		mylog(ERROR, "Invalid condition - continuing in ECHO mode\n");
 		continue;
 	    }
 	    /* find a rule for rewriting the URL */
@@ -151,7 +151,7 @@ int main(int argc, char **argv)
 		    printf("%s %s %s %s\n",
 			   redirect_url, src_addr, ident, method);
 		    fflush(stdout);
-		    log(MATCH, "%s %s %s %d\n", src_addr, url, redirect_url,
+		    mylog(MATCH, "%s %s %s %d\n", src_addr, url, redirect_url,
 			val);
 		}
 	    }
--- a/pattern_list.c
+++ b/pattern_list.c
@@ -79,7 +79,7 @@ add_to_patterns(char *pattern, pattern_i
     stored = sscanf(pattern, "%s %s %s", type, first, second);
 #endif
     if((stored < 2) || (stored > 4)) {
-	log(ERROR, "unable to get a pair of patterns in add_to_patterns() "
+	mylog(ERROR, "unable to get a pair of patterns in add_to_patterns() "
 	    "for [%s]\n", pattern);
 	echo_mode = 1;
 	return;
@@ -99,21 +99,21 @@ add_to_patterns(char *pattern, pattern_i
     }
     
     if(regcomp(&compiled, first, regex_flags)) {
-	log(ERROR, "Invalid regex [%s] in pattern file\n", first);
+	mylog(ERROR, "Invalid regex [%s] in pattern file\n", first);
 	echo_mode = 1;
 	return;
     }
     rpattern.cpattern = compiled;
     rpattern.pattern = (char *)malloc(sizeof(char) * (strlen(first) +1));
     if(rpattern.pattern == NULL) {
-	log(ERROR, "unable to allocate memory in add_to_patterns()\n");
+	mylog(ERROR, "unable to allocate memory in add_to_patterns()\n");
 	echo_mode = 1;
 	return;
     }
     strcpy(rpattern.pattern, first);
     rpattern.replacement = (char *)malloc(sizeof(char) * (strlen(second) +1));
     if(rpattern.replacement == NULL) {
-	log(ERROR, "unable to allocate memory in add_to_patterns()\n");
+	mylog(ERROR, "unable to allocate memory in add_to_patterns()\n");
 	echo_mode = 1;
 	return;
     }
@@ -126,7 +126,7 @@ add_to_patterns(char *pattern, pattern_i
 	rpattern.accel = get_accel(accel, &rpattern.accel_type, 
 				   rpattern.case_sensitive);
 	if(rpattern.accel == NULL) {
-	    log(ERROR, "unable to allocate memory from get_accel()\n");
+	    mylog(ERROR, "unable to allocate memory from get_accel()\n");
 	    echo_mode = 1;
 	    return;
 	}
@@ -219,7 +219,7 @@ add_to_plist(pattern_item pattern, patte
 	curr->next = new;
     }
     if(! new) {
-	log(ERROR, "unable to allocate memory in add_to_plist()\n");
+	mylog(ERROR, "unable to allocate memory in add_to_plist()\n");
 	/* exit(3); */
 	echo_mode = 1;
 	return;
--- a/rewrite.c
+++ b/rewrite.c
@@ -111,11 +111,11 @@ parse_buff(char *buff, char **url, char
 	    if ( end[i] )
 		*end[i] = ' ';
 	}
-	log(ERROR, "incorrect input (%d): %s", c, buff);
+	mylog(ERROR, "incorrect input (%d): %s", c, buff);
 	return 1;
     }
 #ifdef DEBUG
-    log(DEBG, "Request: %s %s %s %s\n", *url, *src_addr, *ident, *method);
+    mylog(DEBG, "Request: %s %s %s %s\n", *url, *src_addr, *ident, *method);
 #endif    
     
     /* all methods must be GET or ICP_QUERY */
@@ -130,14 +130,14 @@ parse_buff(char *buff, char **url, char
 	    if ( end[c] )
 		*end[c] = ' ';
 	}
-	log(DEBG, "method not \"GET\" %s\n", buff);
+	mylog(DEBG, "method not \"GET\" %s\n", buff);
 #endif	
 	return 1;
     }
 	    
     /* URL with less than 7 char is invalid */
     if(strlen(*url) <= 7) {
-	log(ERROR, "strlen url to short (%d)\n", strlen(*url));
+	mylog(ERROR, "strlen url to short (%d)\n", strlen(*url));
 	return 1;
     }
 
@@ -150,7 +150,7 @@ parse_buff(char *buff, char **url, char
        it is already loaded, when squid runs - so not much waste of
        memory ;-) */
     if ( (address.s_addr = inet_addr(*src_addr)) == -1 ) {
-	log(ERROR, "client IP address not valid %s\n",
+	mylog(ERROR, "client IP address not valid %s\n",
 	    *src_addr ? *src_addr : "");
 	if ( token )
 	    *token = '/';
@@ -162,7 +162,7 @@ parse_buff(char *buff, char **url, char
     /* make sure the IP source address matches that of the ones in our list */
     if( ip_access_check(address, ip) == IP_DENY ) {
 #ifdef DEBUG
-	log(DEBG, "client IP address %s not matched\n", *src_addr);
+	mylog(DEBG, "client IP address %s not matched\n", *src_addr);
 #endif  
 	return 1;
     }
@@ -199,7 +199,7 @@ pattern_compare(char *url,char *newurl,
 	    }
 	    if(matched) {
 #ifdef DEBUG
-		log(DEBG, "abort pattern matched: %s (rule %d)\n",
+		mylog(DEBG, "abort pattern matched: %s (rule %d)\n",
 		    url, pattern_no);
 #endif		
 		return (0 - pattern_no); /* URL matches abort file extension */
@@ -215,7 +215,7 @@ pattern_compare(char *url,char *newurl,
 			       curr->accel_type, 
 			       curr->case_sensitive)) {
 #ifdef DEBUG
-		    log(DEBG, "URL %s matches accelerator %s (rule %d)\n",
+		    mylog(DEBG, "URL %s matches accelerator %s (rule %d)\n",
 			url, curr->accel, pattern_no);
 #endif		    
 		    /* Now we must test for normal or extended */
--- a/util.c
+++ b/util.c
@@ -100,6 +100,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <signal.h>
+#include <string.h>
 
 #include "util.h"
 #include "log.h"
@@ -109,7 +110,7 @@ void
 HUPhandler(int kill)
 {
     sig_hup = 1;
-    log(ERROR, "HUP received.  Reconfiguring....\n");
+    mylog(ERROR, "HUP received.  Reconfiguring....\n");
     signal(SIGHUP, HUPhandler);
 }
 
@@ -117,7 +118,7 @@ void
 KILLhandler(int kill)
 {
     sig_hup = 1;
-    log(ERROR, "KILL received.  Shutting down....\n");
+    mylog(ERROR, "KILL received.  Shutting down....\n");
     closeLogs();
     exit(1);
 }
@@ -150,7 +151,7 @@ savestr(const char *str)
         save = (char *)malloc(strlen(str) + 1);
         if ( save == NULL ) {
             perror("Problems allocating memory for a string:");
-            log(ERROR,"Problems allocating memory for \"%s\"",str);
+            mylog(ERROR,"Problems allocating memory for \"%s\"",str);
         }
         else {
             strcpy(save, str);