Browse code

bb#8993 - Rename the STAT macro to CLAMSTAT to avoid name conflicts on AIX

Shawn Webb authored on 2013/09/26 05:22:18
Showing 18 changed files
... ...
@@ -275,7 +275,7 @@ int main(int argc, char **argv)
275 275
 
276 276
 #ifdef C_LINUX
277 277
     procdev = 0;
278
-    if(STAT("/proc", &sb) != -1 && !sb.st_size)
278
+    if(CLAMSTAT("/proc", &sb) != -1 && !sb.st_size)
279 279
 	procdev = sb.st_dev;
280 280
 #endif
281 281
 
... ...
@@ -92,7 +92,7 @@ int localserver(const struct optstruct *opts)
92 92
 		    close(sockfd);
93 93
 		    return -1;
94 94
 		}
95
-	    } else if(STAT(server.sun_path, &foo) != -1) {
95
+	    } else if(CLAMSTAT(server.sun_path, &foo) != -1) {
96 96
 		logg("!LOCAL: Socket file %s exists. Either remove it, or configure a different one.\n", server.sun_path);
97 97
 		close(sockfd);
98 98
 		return -1;
... ...
@@ -876,7 +876,7 @@ fan_checkowner (int pid, const struct optstruct *opts)
876 876
         return 0;
877 877
 
878 878
     snprintf (path, sizeof (path), "/proc/%u", pid);
879
-    if (STAT (path, &sb) == 0)
879
+    if (CLAMSTAT (path, &sb) == 0)
880 880
     {
881 881
         while (opt)
882 882
         {
... ...
@@ -325,7 +325,7 @@ int scan_pathchk(const char *path, struct cli_ftw_cbdata *data)
325 325
     }
326 326
 
327 327
     if(!optget(scandata->opts, "CrossFilesystems")->enabled) {
328
-	if(STAT(path, &statbuf) == 0) {
328
+	if(CLAMSTAT(path, &statbuf) == 0) {
329 329
 	    if(statbuf.st_dev != scandata->dev) {
330 330
 		if(scandata->type != TYPE_MULTISCAN)
331 331
 		    conn_reply_single(scandata->conn, path, "Excluded (another filesystem)");
... ...
@@ -236,7 +236,7 @@ int command(client_conn_t *conn, int *virus)
236 236
 	    int multiscan, max, alive;
237 237
 
238 238
 	    /* use MULTISCAN only for directories (bb #1869) */
239
-	    if (STAT(conn->filename, &sb) == 0 &&
239
+	    if (CLAMSTAT(conn->filename, &sb) == 0 &&
240 240
 		!S_ISDIR(sb.st_mode)) {
241 241
 		thrmgr_setactivetask(NULL, "CONTSCAN");
242 242
 		type = TYPE_CONTSCAN;
... ...
@@ -384,7 +384,7 @@ int command(client_conn_t *conn, int *virus)
384 384
 	 flags |= CLI_FTW_FOLLOW_FILE_SYMLINK;
385 385
 
386 386
      if(!optget(opts, "CrossFilesystems")->enabled)
387
-	 if(STAT(conn->filename, &sb) == 0)
387
+	 if(CLAMSTAT(conn->filename, &sb) == 0)
388 388
 	     scandata.dev = sb.st_dev;
389 389
 
390 390
      ret = cli_ftw(conn->filename, flags,  maxdirrec ? maxdirrec : INT_MAX, scan_callback, &data, scan_pathchk);
... ...
@@ -296,7 +296,7 @@ int dsresult(int sockd, int scantype, const char *filename, int *printok, int *e
296 296
 	    logg("STDIN: noreply from clamd\n.");
297 297
 	    return -1;
298 298
 	}
299
-        if(STAT(filename, &sb) == -1) {
299
+        if(CLAMSTAT(filename, &sb) == -1) {
300 300
 	    logg("~%s: stat() failed with %s, clamd may not be responding\n",
301 301
 		 filename, strerror(errno));
302 302
 	    return -1;
... ...
@@ -249,7 +249,7 @@ static void scanfile(const char *filename, struct cl_engine *engine, const struc
249 249
     }
250 250
 
251 251
     /* argh, don't scan /proc files */
252
-    if(STAT(filename, &sb) != -1) {
252
+    if(CLAMSTAT(filename, &sb) != -1) {
253 253
 #ifdef C_LINUX
254 254
 	if(procdev && sb.st_dev == procdev) {
255 255
 	    if(!printinfected)
... ...
@@ -412,7 +412,7 @@ static void scandirs(const char *dirname, struct cl_engine *engine, const struct
412 412
 			    if(dirlnk != 2 && filelnk != 2) {
413 413
 				if(!printinfected)
414 414
 				    logg("%s: Symbolic link\n", fname);
415
-			    } else if(STAT(fname, &sb) != -1) {
415
+			    } else if(CLAMSTAT(fname, &sb) != -1) {
416 416
 				if(S_ISREG(sb.st_mode) && filelnk == 2) {
417 417
 				    scanfile(fname, engine, opts, options);
418 418
 				} else if(S_ISDIR(sb.st_mode) && dirlnk == 2) {
... ...
@@ -884,7 +884,7 @@ int scanmanager(const struct optstruct *opts)
884 884
 
885 885
 #ifdef C_LINUX
886 886
     procdev = (dev_t) 0;
887
-    if(STAT("/proc", &sb) != -1 && !sb.st_size)
887
+    if(CLAMSTAT("/proc", &sb) != -1 && !sb.st_size)
888 888
 	procdev = sb.st_dev;
889 889
 #endif
890 890
 
... ...
@@ -895,7 +895,7 @@ int scanmanager(const struct optstruct *opts)
895 895
 	    logg("!Can't get absolute pathname of current working directory\n");
896 896
 	    ret = 2;
897 897
 	} else {
898
-	    STAT(cwd, &sb);
898
+	    CLAMSTAT(cwd, &sb);
899 899
 	    scandirs(cwd, engine, opts, options, 1, sb.st_dev);
900 900
 	}
901 901
 
... ...
@@ -923,7 +923,7 @@ int scanmanager(const struct optstruct *opts)
923 923
 		    if(dirlnk == 0 && filelnk == 0) {
924 924
 			if(!printinfected)
925 925
 			    logg("%s: Symbolic link\n", file);
926
-		    } else if(STAT(file, &sb) != -1) {
926
+		    } else if(CLAMSTAT(file, &sb) != -1) {
927 927
 			if(S_ISREG(sb.st_mode) && filelnk) {
928 928
 			    scanfile(file, engine, opts, options);
929 929
 			} else if(S_ISDIR(sb.st_mode) && dirlnk) {
... ...
@@ -333,7 +333,7 @@ main (int argc, char **argv)
333 333
 
334 334
     if (optget (opts, "HTTPProxyPassword")->enabled)
335 335
     {
336
-        if (STAT (cfgfile, &statbuf) == -1)
336
+        if (CLAMSTAT (cfgfile, &statbuf) == -1)
337 337
         {
338 338
             logg ("^Can't stat %s (critical error)\n", cfgfile);
339 339
             optfree (opts);
... ...
@@ -2621,7 +2621,7 @@ updatecustomdb (const char *url, int *signo, const struct optstruct *opts,
2621 2621
         rtimeout = optget (opts, "ReceiveTimeout")->numarg;
2622 2622
 
2623 2623
         *mtime = 0;
2624
-        if (STAT (dbname, &sb) != -1)
2624
+        if (CLAMSTAT (dbname, &sb) != -1)
2625 2625
             Rfc2822DateTime (mtime, sb.st_mtime);
2626 2626
 
2627 2627
         newfile = cli_gentemp (updtmpdir);
... ...
@@ -29,14 +29,14 @@
29 29
 #include <unistd.h>
30 30
 
31 31
 #define STATBUF struct stat64
32
-#define STAT stat64
32
+#define CLAMSTAT stat64
33 33
 #define LSTAT lstat64
34 34
 #define FSTAT fstat64
35 35
 #define safe_open(a, b) open(a, b|O_LARGEFILE)
36 36
 #else
37 37
 
38 38
 #define STATBUF struct stat
39
-#define STAT stat
39
+#define CLAMSTAT stat
40 40
 #define LSTAT lstat
41 41
 #define FSTAT fstat
42 42
 /* Nothing is safe in windows, not even open, safe_open defined under /win32 */
... ...
@@ -2813,7 +2813,7 @@ rfc1341(message *m, const char *dir)
2813 2813
 	} else if(errno == EEXIST) {
2814 2814
 		STATBUF statb;
2815 2815
 
2816
-		if(STAT(pdir, &statb) < 0) {
2816
+		if(CLAMSTAT(pdir, &statb) < 0) {
2817 2817
 			char err[128];
2818 2818
 			cli_errmsg("Partial directory %s: %s\n", pdir,
2819 2819
 				cli_strerror(errno, err, sizeof(err)));
... ...
@@ -903,7 +903,7 @@ cli_rmdirs(const char *name)
903 903
 	char err[128];
904 904
 
905 905
 
906
-    if(STAT(name, &statb) < 0) {
906
+    if(CLAMSTAT(name, &statb) < 0) {
907 907
 	cli_warnmsg("cli_rmdirs: Can't locate %s: %s\n", name, cli_strerror(errno, err, sizeof(err)));
908 908
 	return -1;
909 909
     }
... ...
@@ -974,7 +974,7 @@ int cli_rmdirs(const char *dirname)
974 974
 
975 975
     chmod(dirname, 0700);
976 976
     if((dd = opendir(dirname)) != NULL) {
977
-	while(STAT(dirname, &maind) != -1) {
977
+	while(CLAMSTAT(dirname, &maind) != -1) {
978 978
 	    if(!rmdir(dirname)) break;
979 979
 	    if(errno != ENOTEMPTY && errno != EEXIST && errno != EBADF) {
980 980
 		cli_errmsg("cli_rmdirs: Can't remove temporary directory %s: %s\n", dirname, cli_strerror(errno, err, sizeof(err)));
... ...
@@ -520,7 +520,7 @@ static int get_filetype(const char *fname, int flags, int need_stat,
520 520
     }
521 521
 
522 522
     if (need_stat) {
523
-	if (STAT(fname, statbuf) == -1)
523
+	if (CLAMSTAT(fname, statbuf) == -1)
524 524
 	    return -1;
525 525
 	stated = 1;
526 526
     }
... ...
@@ -2908,7 +2908,7 @@ int cl_load(const char *path, struct cl_engine *engine, unsigned int *signo, uns
2908 2908
 	return CL_EARG;
2909 2909
     }
2910 2910
 
2911
-    if(STAT(path, &sb) == -1) {
2911
+    if(CLAMSTAT(path, &sb) == -1) {
2912 2912
         cli_errmsg("cl_load(): Can't get status of %s\n", path);
2913 2913
         return CL_ESTAT;
2914 2914
     }
... ...
@@ -3028,7 +3028,7 @@ int cl_statinidir(const char *dirname, struct cl_stat *dbstat)
3028 3028
 
3029 3029
 		strcpy(dbstat->statdname[dbstat->entries - 1], dent->d_name);
3030 3030
 #endif
3031
-		STAT(fname, &dbstat->stattab[dbstat->entries - 1]);
3031
+		CLAMSTAT(fname, &dbstat->stattab[dbstat->entries - 1]);
3032 3032
 		free(fname);
3033 3033
 	    }
3034 3034
 	}
... ...
@@ -3083,7 +3083,7 @@ int cl_statchkdir(const struct cl_stat *dbstat)
3083 3083
 		}
3084 3084
 
3085 3085
 		sprintf(fname, "%s"PATHSEP"%s", dbstat->dir, dent->d_name);
3086
-		STAT(fname, &sb);
3086
+		CLAMSTAT(fname, &sb);
3087 3087
 		free(fname);
3088 3088
 
3089 3089
 		found = 0;
... ...
@@ -3433,7 +3433,7 @@ int cl_countsigs(const char *path, unsigned int countoptions, unsigned int *sigs
3433 3433
     if(!sigs)
3434 3434
 	return CL_ENULLARG;
3435 3435
 
3436
-    if(STAT(path, &sb) == -1) {
3436
+    if(CLAMSTAT(path, &sb) == -1) {
3437 3437
 	cli_errmsg("cl_countsigs: Can't stat %s\n", path);
3438 3438
 	return CL_ESTAT;
3439 3439
     }
... ...
@@ -123,7 +123,7 @@ static void action_remove(const char *filename) {
123 123
 
124 124
 static int isdir(void) {
125 125
     STATBUF sb;
126
-    if(STAT(actarget, &sb) || !S_ISDIR(sb.st_mode)) {
126
+    if(CLAMSTAT(actarget, &sb) || !S_ISDIR(sb.st_mode)) {
127 127
 	logg("!'%s' doesn't exist or is not a directory\n", actarget);
128 128
 	return 0;
129 129
     }
... ...
@@ -261,7 +261,7 @@ static int logg_open(void)
261 261
 
262 262
     if(logg_file)
263 263
         if(logg_size > 0)
264
-            if(STAT(logg_file, &sb) != -1)
264
+            if(CLAMSTAT(logg_file, &sb) != -1)
265 265
                 if(sb.st_size > logg_size)
266 266
 	                if (rename_logg(&sb))
267 267
                         return -1;
... ...
@@ -172,7 +172,7 @@ static int hashsig(const struct optstruct *opts, unsigned int mdb, int type)
172 172
 
173 173
     if(opts->filename) {
174 174
 	for(i = 0; opts->filename[i]; i++) {
175
-	    if(STAT(opts->filename[i], &sb) == -1) {
175
+	    if(CLAMSTAT(opts->filename[i], &sb) == -1) {
176 176
 		mprintf("!hashsig: Can't access file %s\n", opts->filename[i]);
177 177
 		perror("hashsig");
178 178
 		return -1;
... ...
@@ -523,7 +523,7 @@ static int script2cdiff(const char *script, const char *builder, const struct op
523 523
 	int bytes;
524 524
 
525 525
 
526
-    if(STAT(script, &sb) == -1) {
526
+    if(CLAMSTAT(script, &sb) == -1) {
527 527
 	mprintf("!script2diff: Can't stat file %s\n", script);
528 528
 	return -1;
529 529
     }
... ...
@@ -669,7 +669,7 @@ static int build(const struct optstruct *opts)
669 669
     if(optget(opts, "datadir")->active)
670 670
 	localdbdir = optget(opts, "datadir")->strarg;
671 671
 
672
-    if(STAT("COPYING", &foo) == -1) {
672
+    if(CLAMSTAT("COPYING", &foo) == -1) {
673 673
 	mprintf("!build: COPYING file not found in current working directory.\n");
674 674
 	return -1;
675 675
     }
... ...
@@ -1439,7 +1439,7 @@ static int listsigs(const struct optstruct *opts, int mode)
1439 1439
 	name = optget(opts, "list-sigs")->strarg;
1440 1440
 	if(access(name, R_OK) && localdbdir)
1441 1441
 	    name = localdbdir;
1442
-	if(STAT(name, &sb) == -1) {
1442
+	if(CLAMSTAT(name, &sb) == -1) {
1443 1443
 	    mprintf("--list-sigs: Can't get status of %s\n", name);
1444 1444
 	    return -1;
1445 1445
 	}
... ...
@@ -1832,7 +1832,7 @@ static int dircopy(const char *src, const char *dest)
1832 1832
 	char spath[512], dpath[512];
1833 1833
 
1834 1834
 
1835
-    if(STAT(dest, &sb) == -1) {
1835
+    if(CLAMSTAT(dest, &sb) == -1) {
1836 1836
 	if(mkdir(dest, 0755)) {
1837 1837
 	    /* mprintf("!dircopy: Can't create temporary directory %s\n", dest); */
1838 1838
 	    return -1;
... ...
@@ -3036,7 +3036,7 @@ int main(int argc, char **argv)
3036 3036
 	    mprintf("!--verify-cdiff requires two arguments\n");
3037 3037
 	    ret = -1;
3038 3038
 	} else {
3039
-	    if(STAT(opts->filename[0], &sb) == -1) {
3039
+	    if(CLAMSTAT(opts->filename[0], &sb) == -1) {
3040 3040
 		mprintf("--verify-cdiff: Can't get status of %s\n", opts->filename[0]);
3041 3041
 		ret = -1;
3042 3042
 	    } else {
... ...
@@ -350,7 +350,7 @@ static size_t prepare_instream(char *buf, size_t off, size_t buflen)
350 350
     STATBUF stbuf;
351 351
     int fd, nread;
352 352
     uint32_t chunk;
353
-    fail_unless_fmt(STAT(SCANFILE, &stbuf) != -1, "stat failed for %s: %s", SCANFILE, strerror(errno));
353
+    fail_unless_fmt(CLAMSTAT(SCANFILE, &stbuf) != -1, "stat failed for %s: %s", SCANFILE, strerror(errno));
354 354
 
355 355
     fd = open(SCANFILE, O_RDONLY);
356 356
     fail_unless_fmt(fd != -1, "open failed: %s\n", strerror(errno));