*/
#include <stdio.h>
-#include "monitor.h"
-#include "sysemu.h"
+#include "monitor/monitor.h"
/*
* Print to current monitor if we have one, else to stderr.
va_end(ap);
}
+void error_printf_unless_qmp(const char *fmt, ...)
+{
+ va_list ap;
+
+ if (!monitor_cur_is_qmp()) {
+ va_start(ap, fmt);
+ error_vprintf(fmt, ap);
+ va_end(ap);
+ }
+}
+
static Location std_loc = {
.kind = LOC_NONE
};
progname = p ? p + 1 : argv0;
}
+const char *error_get_progname(void)
+{
+ return progname;
+}
+
/*
* Print current location to current monitor if we have one, else to stderr.
*/
int i;
const char *const *argp;
- if (!cur_mon) {
+ if (!cur_mon && progname) {
fprintf(stderr, "%s:", progname);
sep = " ";
}
error_printf(" ");
break;
default:
- error_printf(sep);
+ error_printf("%s", sep);
}
}
/*
* Print an error message to current monitor if we have one, else to stderr.
+ * Format arguments like sprintf(). The result should not contain
+ * newlines.
* Prepend the current location and append a newline.
* It's wrong to call this in a QMP monitor. Use qerror_report() there.
*/
va_end(ap);
error_printf("\n");
}
-
-void qerror_report_internal(const char *file, int linenr, const char *func,
- const char *fmt, ...)
-{
- va_list va;
- QError *qerror;
-
- va_start(va, fmt);
- qerror = qerror_from_info(file, linenr, func, fmt, &va);
- va_end(va);
-
- if (cur_mon) {
- monitor_set_error(cur_mon, qerror);
- } else {
- qerror_print(qerror);
- QDECREF(qerror);
- }
-}