summaryrefslogtreecommitdiff
path: root/src/msg.c
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2008-02-12 21:28:56 -0800
committerAaron Plattner <aplattner@nvidia.com>2008-02-12 21:28:56 -0800
commitfb518983907cf33ab8ee7e71ef79fe920b6b5a17 (patch)
tree16dd7342ea2734bcd6c0bafa23fae939af971f96 /src/msg.c
parent429a78a02af06685581968d1be658f1fa33c2312 (diff)
1.0-96261.0-9626
Diffstat (limited to 'src/msg.c')
-rw-r--r--src/msg.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/msg.c b/src/msg.c
index 002f2b4..a176cd2 100644
--- a/src/msg.c
+++ b/src/msg.c
@@ -23,6 +23,7 @@
*/
#include "msg.h"
+#include "command-line.h"
#include <stdio.h>
#include <stdarg.h>
@@ -35,6 +36,8 @@
#include <sys/termios.h>
#endif
+extern int __verbosity;
+
static void format(FILE*, const char*, char *);
static int get_terminal_width(void);
@@ -49,10 +52,14 @@ do { \
/*
* nv_error_msg() - print an error message, nicely formatted using the
* format() function.
+ *
+ * This function should be used for all errors.
*/
void nv_error_msg(const char *fmt, ...)
{
+ if (__verbosity < VERBOSITY_ERROR) return;
+
fprintf(stderr, "\n");
NV_FORMAT(stderr, "ERROR: ", fmt);
@@ -66,10 +73,14 @@ void nv_error_msg(const char *fmt, ...)
/*
* nv_warning_msg() - print a warning message, nicely formatted using
* the format() function.
+ *
+ * This function should be used for all warnings.
*/
void nv_warning_msg(const char *fmt, ...)
{
+ if (__verbosity < VERBOSITY_WARNING) return;
+
fprintf(stdout, "\n");
NV_FORMAT(stdout, "WARNING: ", fmt);
@@ -81,8 +92,28 @@ void nv_warning_msg(const char *fmt, ...)
/*
+ * nv_info_msg() - print an info message, nicely formatted using
+ * the format() function.
+ *
+ * This function should be used to display verbose information.
+ */
+
+void nv_info_msg(const char *prefix, const char *fmt, ...)
+{
+ if (__verbosity < VERBOSITY_ALL) return;
+
+ NV_FORMAT(stdout, prefix, fmt);
+
+} /* nv_info_msg() */
+
+
+
+/*
* nv_msg() - print a message, nicely formatted using the format()
* function.
+ *
+ * This function should be used to display messages independent
+ * of the verbosity level.
*/
void nv_msg(const char *prefix, const char *fmt, ...)
@@ -159,7 +190,7 @@ static void format(FILE *stream, const char *prefix,
if (b <= a) {
b = a;
- while (!isspace(*b)) b++;
+ while (*b && !isspace(*b)) b++;
}
}