commit:fd07ab46f5f37057e9290441931d5de92d62761b
author:Chip Black
committer:Chip Black
date:Sun Jun 2 22:38:25 2013 -0500
parents:767693caf2b41c2e857688d10d2c71bc77c0bbad
Add mute support to blergtool
diff --git a/tools/blergtool.c b/tools/blergtool.c
line changes: +24/-3
index b0e7368..ab98a94
--- a/tools/blergtool.c
+++ b/tools/blergtool.c
@@ -50,10 +50,11 @@ int main(int argc, char *argv[]) {
 
 		char *data;
 		int size;
-		blerg_fetch(f, record, &data, &size);
+		if (blerg_fetch(f, record, &data, &size)) {
+			fwrite(data, 1, size, stdout);
+			free(data);
+		}
 		blerg_close(f);
-		fwrite(data, 1, size, stdout);
-		free(data);
 	} else if (strncmp(argv[1], "list", 4) == 0) {
 		char *tag = argv[2];
 		int count = 50;
@@ -67,6 +68,26 @@ int main(int argc, char *argv[]) {
 			}
 			free(list);
 		}
+	} else if (strncmp(argv[1], "mute", 4) == 0) {
+		char *store = argv[2];
+		struct blerg *f = blerg_open(store);
+		if (!f) {
+			printf("Blerg open failed\n");
+			exit(1);
+		}
+
+		blerg_set_mute(f, 1);
+		blerg_close(f);
+	} else if (strncmp(argv[1], "unmute", 6) == 0) {
+		char *store = argv[2];
+		struct blerg *f = blerg_open(store);
+		if (!f) {
+			printf("Blerg open failed\n");
+			exit(1);
+		}
+
+		blerg_set_mute(f, 0);
+		blerg_close(f);
 	} else {
 		help();
 	}