Browse Source

Add q() macro that checks quiet flag.

Georgi Chorbadzhiyski 9 years ago
parent
commit
e16243a5d8
2 changed files with 12 additions and 8 deletions
  1. 6
    8
      cmd.c
  2. 6
    0
      data.h

+ 6
- 8
cmd.c View File

68
 	}
68
 	}
69
 
69
 
70
 	if (!v) {
70
 	if (!v) {
71
-		if (!quiet) {
72
-			fprintf(stderr, "WARNING: Videohub sent unknown command!\n");
73
-			fprintf(stderr, "         Please report this command to author's email: georgi@unixsol.org\n");
74
-			fprintf(stderr, "         You may use -q or --quiet to suppress the message.\n");
75
-			fprintf(stderr, "---------8<-----------8<----------- cut here ---------8<------------8<---------\n");
76
-			fprintf(stderr, "%s\n", cmd);
77
-			fprintf(stderr, "---------8<-----------8<----------- cut here ---------8<------------8<---------\n");
78
-		}
71
+		q("WARNING: Videohub sent unknown command!\n");
72
+		q("         Please report this command to author's email: georgi@unixsol.org\n");
73
+		q("         You may use -q or --quiet to suppress the message.\n");
74
+		q("---------8<-----------8<----------- cut here ---------8<------------8<---------\n");
75
+		q("%s\n", cmd);
76
+		q("---------8<-----------8<----------- cut here ---------8<------------8<---------\n");
79
 		return false;
77
 		return false;
80
 	}
78
 	}
81
 
79
 

+ 6
- 0
data.h View File

68
 			printf("debug: " fmt, ## arguments); \
68
 			printf("debug: " fmt, ## arguments); \
69
 	} while(0)
69
 	} while(0)
70
 
70
 
71
+#define q(fmt, arguments...) \
72
+	do { \
73
+		if (!quiet) \
74
+			fprintf(stderr, fmt, ## arguments); \
75
+	} while(0)
76
+
71
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
77
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
72
 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
78
 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
73
 #define UNUSED(x) UNUSED_ ## x __attribute__((unused))
79
 #define UNUSED(x) UNUSED_ ## x __attribute__((unused))

Loading…
Cancel
Save