summaryrefslogtreecommitdiffstats
path: root/fastboot/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fastboot/util.cpp')
-rw-r--r--fastboot/util.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/fastboot/util.cpp b/fastboot/util.cpp
index 53fc1be29..140270fd9 100644
--- a/fastboot/util.cpp
+++ b/fastboot/util.cpp
@@ -35,6 +35,8 @@
#include "fastboot.h"
+static bool g_verbose = false;
+
double now() {
struct timeval tv;
gettimeofday(&tv, NULL);
@@ -46,11 +48,28 @@ void die(const char* fmt, ...) {
va_start(ap, fmt);
fprintf(stderr, "fastboot: error: ");
vfprintf(stderr, fmt, ap);
- fprintf(stderr,"\n");
+ fprintf(stderr, "\n");
va_end(ap);
exit(EXIT_FAILURE);
}
+void set_verbose() {
+ g_verbose = true;
+}
+
+void verbose(const char* fmt, ...) {
+ if (!g_verbose) return;
+
+ if (*fmt != '\n') {
+ va_list ap;
+ va_start(ap, fmt);
+ fprintf(stderr, "fastboot: verbose: ");
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ }
+ fprintf(stderr, "\n");
+}
+
char* xstrdup(const char* s) {
char* result = strdup(s);
if (!result) die("out of memory");