Blame SOURCES/powertop-2.9-powertop-2.3-compat.patch

3c78c1
From fa86b4030ae67b7a8445c831493bba551c6613e8 Mon Sep 17 00:00:00 2001
3c78c1
From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= <jskarvad@redhat.com>
3c78c1
Date: Fri, 4 May 2018 14:56:13 +0200
3c78c1
Subject: [PATCH] RHEL-7 PowerTOP 2.3 compatibility patch
3c78c1
MIME-Version: 1.0
3c78c1
Content-Type: text/plain; charset=UTF-8
3c78c1
Content-Transfer-Encoding: 8bit
3c78c1
3c78c1
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
3c78c1
---
3c78c1
 doc/powertop.8                        |  22 ++++--
3c78c1
 src/Makefile.am                       |   2 +
3c78c1
 src/Makefile.in                       |  20 +++++
3c78c1
 src/main.cpp                          |  17 +++--
3c78c1
 src/report/report-formatter-plain.cpp | 133 ++++++++++++++++++++++++++++++++++
3c78c1
 src/report/report-formatter-plain.h   |  54 ++++++++++++++
3c78c1
 src/report/report-maker.cpp           |   3 +
3c78c1
 src/report/report-maker.h             |   5 +-
3c78c1
 src/report/report.cpp                 |  53 ++++++++------
3c78c1
 9 files changed, 275 insertions(+), 34 deletions(-)
3c78c1
 create mode 100644 src/report/report-formatter-plain.cpp
3c78c1
 create mode 100644 src/report/report-formatter-plain.h
3c78c1
3c78c1
diff --git a/doc/powertop.8 b/doc/powertop.8
3c78c1
index 60e3c73..c18344d 100644
3c78c1
--- a/doc/powertop.8
3c78c1
+++ b/doc/powertop.8
3c78c1
@@ -23,12 +23,20 @@ can get more accurate estimates by using this option to enable a
3c78c1
 calibration cycle.  This will cycle through various display levels and
3c78c1
 USB device activities and workloads.
3c78c1
 .TP
3c78c1
-\fB\-C\fR, \fB\-\-csv\fR[=\fIfilename\fR]
3c78c1
+\fB\-C\fR[\fIfilename\fR], \fB\-\-csv\fR[=\fIfilename\fR]
3c78c1
 Generate a CSV report.  If a
3c78c1
 .I filename
3c78c1
 is not specified then the default name
3c78c1
 .B powertop.csv
3c78c1
-is used.  The CSV report can be used for reporting and data analysis.
3c78c1
+is used. If a
3c78c1
+.I filename
3c78c1
+is "\fB\-\fR" then STDOUT is used. The CSV report can
3c78c1
+be used for reporting and data analysis.
3c78c1
+.TP
3c78c1
+\fB\-d\fR[\fIfilename\fR], \fB\-\-dump\fR[=\fIfilename\fR]
3c78c1
+Generate a plain text report.  If a
3c78c1
+.I filename
3c78c1
+is not specified or it is "\fB\-\fR" then STDOUT is used.
3c78c1
 .TP
3c78c1
 .B \-\-debug
3c78c1
 Run in debug mode.
3c78c1
@@ -39,13 +47,15 @@ specify the serial device node of the serial to USB adaptor connecting to
3c78c1
 the Extech Power Analyzer, for example
3c78c1
 .IR /dev/ttyUSB0 .
3c78c1
 .TP
3c78c1
-\fB\-r\fR, \fB\-\-html\fR[=\fIfilename\fR]
3c78c1
+\fB\-r\fR[\fIfilename\fR], \fB\-h\fR[\fIfilename\fR], \fB\-\-html\fR[=\fIfilename\fR]
3c78c1
 Generate an HTML report.  If a
3c78c1
 .I filename
3c78c1
 is not specified then the default name
3c78c1
 .B powertop.html
3c78c1
-is used.  The HTML report can be sent to others to help diagnose power
3c78c1
-issues.
3c78c1
+is used. If a
3c78c1
+.I filename
3c78c1
+is "\fB\-\fR" then STDOUT is used. The HTML report can be sent to others to help
3c78c1
+diagnose power issues.
3c78c1
 .TP
3c78c1
 \fB\-i\fR, \fB\-\-iteration\fR[=\fIiterations\fR]
3c78c1
 Number of times to run each test.
3c78c1
@@ -65,7 +75,7 @@ file as a part of calibration before making a report.
3c78c1
 .BR \-V ", " \-\-version
3c78c1
 Print version information and exit.
3c78c1
 .TP
3c78c1
-.BR \-h ", " \-\-help
3c78c1
+.BR \-u ", " \-\-help
3c78c1
 Show the help message and exit.
3c78c1
 .SH COMMANDS
3c78c1
 In interactive mode, the following key bindings are available:
3c78c1
diff --git a/src/Makefile.am b/src/Makefile.am
3c78c1
index 8357bae..5882468 100644
3c78c1
--- a/src/Makefile.am
3c78c1
+++ b/src/Makefile.am
3c78c1
@@ -99,6 +99,8 @@ powertop_SOURCES = \
3c78c1
 	report/report-formatter-csv.h \
3c78c1
 	report/report-formatter-html.cpp \
3c78c1
 	report/report-formatter-html.h \
3c78c1
+	report/report-formatter-plain.cpp \
3c78c1
+	eport/report-formatter-plain.h \
3c78c1
 	report/report-formatter.h \
3c78c1
 	report/report-maker.cpp \
3c78c1
 	report/report-maker.h \
3c78c1
diff --git a/src/Makefile.in b/src/Makefile.in
3c78c1
index 643b7ce..90ebdff 100644
3c78c1
--- a/src/Makefile.in
3c78c1
+++ b/src/Makefile.in
3c78c1
@@ -159,6 +159,7 @@ am_powertop_OBJECTS = powertop-devlist.$(OBJEXT) \
3c78c1
 	report/powertop-report-formatter-base.$(OBJEXT) \
3c78c1
 	report/powertop-report-formatter-csv.$(OBJEXT) \
3c78c1
 	report/powertop-report-formatter-html.$(OBJEXT) \
3c78c1
+	report/powertop-report-formatter-plain.$(OBJEXT) \
3c78c1
 	report/powertop-report-maker.$(OBJEXT) \
3c78c1
 	report/powertop-report.$(OBJEXT) \
3c78c1
 	tuning/powertop-bluetooth.$(OBJEXT) \
3c78c1
@@ -512,6 +513,8 @@ powertop_SOURCES = \
3c78c1
 	report/report-formatter-csv.h \
3c78c1
 	report/report-formatter-html.cpp \
3c78c1
 	report/report-formatter-html.h \
3c78c1
+	report/report-formatter-plain.cpp \
3c78c1
+	report/report-formatter-plain.h \
3c78c1
 	report/report-formatter.h \
3c78c1
 	report/report-maker.cpp \
3c78c1
 	report/report-maker.h \
3c78c1
@@ -806,6 +809,8 @@ report/powertop-report-formatter-csv.$(OBJEXT):  \
3c78c1
 	report/$(am__dirstamp) report/$(DEPDIR)/$(am__dirstamp)
3c78c1
 report/powertop-report-formatter-html.$(OBJEXT):  \
3c78c1
 	report/$(am__dirstamp) report/$(DEPDIR)/$(am__dirstamp)
3c78c1
+report/powertop-report-formatter-plain.$(OBJEXT):  \
3c78c1
+	report/$(am__dirstamp) report/$(DEPDIR)/$(am__dirstamp)
3c78c1
 report/powertop-report-maker.$(OBJEXT): report/$(am__dirstamp) \
3c78c1
 	report/$(DEPDIR)/$(am__dirstamp)
3c78c1
 report/powertop-report.$(OBJEXT): report/$(am__dirstamp) \
3c78c1
@@ -907,6 +912,7 @@ distclean-compile:
3c78c1
 @AMDEP_TRUE@@am__include@ @am__quote@report/$(DEPDIR)/powertop-report-formatter-base.Po@am__quote@
3c78c1
 @AMDEP_TRUE@@am__include@ @am__quote@report/$(DEPDIR)/powertop-report-formatter-csv.Po@am__quote@
3c78c1
 @AMDEP_TRUE@@am__include@ @am__quote@report/$(DEPDIR)/powertop-report-formatter-html.Po@am__quote@
3c78c1
+@AMDEP_TRUE@@am__include@ @am__quote@report/$(DEPDIR)/powertop-report-formatter-plain.Po@am__quote@
3c78c1
 @AMDEP_TRUE@@am__include@ @am__quote@report/$(DEPDIR)/powertop-report-maker.Po@am__quote@
3c78c1
 @AMDEP_TRUE@@am__include@ @am__quote@report/$(DEPDIR)/powertop-report.Po@am__quote@
3c78c1
 @AMDEP_TRUE@@am__include@ @am__quote@tuning/$(DEPDIR)/powertop-bluetooth.Po@am__quote@
3c78c1
@@ -1675,6 +1681,20 @@ report/powertop-report-formatter-html.o: report/report-formatter-html.cpp
3c78c1
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
3c78c1
 @am__fastdepCXX_FALSE@	$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(powertop_CPPFLAGS) $(CPPFLAGS) $(powertop_CXXFLAGS) $(CXXFLAGS) -c -o report/powertop-report-formatter-html.o `test -f 'report/report-formatter-html.cpp' || echo '$(srcdir)/'`report/report-formatter-html.cpp
3c78c1
 
3c78c1
+report/powertop-report-formatter-plain.o: report/report-formatter-plain.cpp
3c78c1
+@am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(powertop_CPPFLAGS) $(CPPFLAGS) $(powertop_CXXFLAGS) $(CXXFLAGS) -MT report/powertop-report-formatter-plain.o -MD -MP -MF report/$(DEPDIR)/powertop-report-formatter-plain.Tpo -c -o report/powertop-report-formatter-plain.o `test -f 'report/report-formatter-plain.cpp' || echo '$(srcdir)/'`report/report-formatter-plain.cpp
3c78c1
+@am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) report/$(DEPDIR)/powertop-report-formatter-plain.Tpo report/$(DEPDIR)/powertop-report-formatter-plain.Po
3c78c1
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='report/report-formatter-plain.cpp' object='report/powertop-report-formatter-plain.o' libtool=no @AMDEPBACKSLASH@
3c78c1
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
3c78c1
+@am__fastdepCXX_FALSE@	$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(powertop_CPPFLAGS) $(CPPFLAGS) $(powertop_CXXFLAGS) $(CXXFLAGS) -c -o report/powertop-report-formatter-plain.o `test -f 'report/report-formatter-plain.cpp' || echo '$(srcdir)/'`report/report-formatter-plain.cpp
3c78c1
+
3c78c1
+report/powertop-report-formatter-plain.obj: report/report-formatter-plain.cpp
3c78c1
+@am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(powertop_CPPFLAGS) $(CPPFLAGS) $(powertop_CXXFLAGS) $(CXXFLAGS) -MT report/powertop-report-formatter-plain.obj -MD -MP -MF report/$(DEPDIR)/powertop-report-formatter-plain.Tpo -c -o report/powertop-report-formatter-plain.obj `if test -f 'report/report-formatter-plain.cpp'; then $(CYGPATH_W) 'report/report-formatter-plain.cpp'; else $(CYGPATH_W) '$(srcdir)/report/report-formatter-plain.cpp'; fi`
3c78c1
+@am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) report/$(DEPDIR)/powertop-report-formatter-plain.Tpo report/$(DEPDIR)/powertop-report-formatter-plain.Po
3c78c1
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='report/report-formatter-palin.cpp' object='report/powertop-report-formatter-plain.obj' libtool=no @AMDEPBACKSLASH@
3c78c1
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
3c78c1
+@am__fastdepCXX_FALSE@	$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(powertop_CPPFLAGS) $(CPPFLAGS) $(powertop_CXXFLAGS) $(CXXFLAGS) -c -o report/powertop-report-formatter-plain.obj `if test -f 'report/report-formatter-plain.cpp'; then $(CYGPATH_W) 'report/report-formatter-plain.cpp'; else $(CYGPATH_W) '$(srcdir)/report/report-formatter-plain.cpp'; fi`
3c78c1
+
3c78c1
 report/powertop-report-formatter-html.obj: report/report-formatter-html.cpp
3c78c1
 @am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(powertop_CPPFLAGS) $(CPPFLAGS) $(powertop_CXXFLAGS) $(CXXFLAGS) -MT report/powertop-report-formatter-html.obj -MD -MP -MF report/$(DEPDIR)/powertop-report-formatter-html.Tpo -c -o report/powertop-report-formatter-html.obj `if test -f 'report/report-formatter-html.cpp'; then $(CYGPATH_W) 'report/report-formatter-html.cpp'; else $(CYGPATH_W) '$(srcdir)/report/report-formatter-html.cpp'; fi`
3c78c1
 @am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) report/$(DEPDIR)/powertop-report-formatter-html.Tpo report/$(DEPDIR)/powertop-report-formatter-html.Po
3c78c1
diff --git a/src/main.cpp b/src/main.cpp
3c78c1
index 7467f0f..769d593 100644
3c78c1
--- a/src/main.cpp
3c78c1
+++ b/src/main.cpp
3c78c1
@@ -84,6 +84,7 @@ static const struct option long_options[] =
3c78c1
 	{"auto-tune",	no_argument,		NULL,		 OPT_AUTO_TUNE},
3c78c1
 	{"calibrate",	no_argument,		NULL,		 'c'},
3c78c1
 	{"csv",		optional_argument,	NULL,		 'C'},
3c78c1
+	{"dump",	optional_argument,	NULL,		 'd'},
3c78c1
 	{"debug",	no_argument,		&debug_learning, OPT_DEBUG},
3c78c1
 	{"extech",	optional_argument,	NULL,		 OPT_EXTECH},
3c78c1
 	{"html",	optional_argument,	NULL,		 'r'},
3c78c1
@@ -93,7 +94,7 @@ static const struct option long_options[] =
3c78c1
 	{"time",	optional_argument,	NULL,		 't'},
3c78c1
 	{"workload",	optional_argument,	NULL,		 'w'},
3c78c1
 	{"version",	no_argument,		NULL,		 'V'},
3c78c1
-	{"help",	no_argument,		NULL,		 'h'},
3c78c1
+	{"help",	no_argument,		NULL,		 'u'},
3c78c1
 	{NULL,		0,			NULL,		 0}
3c78c1
 };
3c78c1
 
3c78c1
@@ -122,16 +123,17 @@ static void print_usage()
3c78c1
 	printf("     --auto-tune\t %s\n", _("sets all tunable options to their GOOD setting"));
3c78c1
 	printf(" -c, --calibrate\t %s\n", _("runs powertop in calibration mode"));
3c78c1
 	printf(" -C, --csv%s\t %s\n", _("[=filename]"), _("generate a csv report"));
3c78c1
+	printf(" -d, --dump%s\t %s\n", _("[=filename]"), _("generate plain text report"));
3c78c1
 	printf("     --debug\t\t %s\n", _("run in \"debug\" mode"));
3c78c1
 	printf("     --extech%s\t %s\n", _("[=devnode]"), _("uses an Extech Power Analyzer for measurements"));
3c78c1
-	printf(" -r, --html%s\t %s\n", _("[=filename]"), _("generate a html report"));
3c78c1
+	printf(" -r, -h, --html%s\t %s\n", _("[=filename]"), _("generate a html report"));
3c78c1
 	printf(" -i, --iteration%s\n", _("[=iterations] number of times to run each test"));
3c78c1
 	printf(" -q, --quiet\t\t %s\n", _("suppress stderr output"));
3c78c1
 	printf(" -s, --sample%s\t %s\n", _("[=seconds]"), _("interval for power consumption measurement"));
3c78c1
 	printf(" -t, --time%s\t %s\n", _("[=seconds]"), _("generate a report for 'x' seconds"));
3c78c1
 	printf(" -w, --workload%s %s\n", _("[=workload]"), _("file to execute for workload"));
3c78c1
 	printf(" -V, --version\t\t %s\n", _("print version information"));
3c78c1
-	printf(" -h, --help\t\t %s\n", _("print this help menu"));
3c78c1
+	printf(" -u, --help\t\t %s\n", _("print this help menu"));
3c78c1
 	printf("\n");
3c78c1
 	printf("%s\n\n", _("For more help please refer to the 'man 8 powertop'"));
3c78c1
 }
3c78c1
@@ -441,7 +443,7 @@ int main(int argc, char **argv)
3c78c1
 #endif
3c78c1
 	ui_notify_user = ui_notify_user_ncurses;
3c78c1
 	while (1) { /* parse commandline options */
3c78c1
-		c = getopt_long(argc, argv, "cC:r:i:qt:w:Vh", long_options, &option_index);
3c78c1
+		c = getopt_long(argc, argv, "cC::d::r::i:qt:w:uVh::", long_options, &option_index);
3c78c1
 		/* Detect the end of the options. */
3c78c1
 		if (c == -1)
3c78c1
 			break;
3c78c1
@@ -471,6 +473,7 @@ int main(int argc, char **argv)
3c78c1
 			checkroot();
3c78c1
 			extech_power_meter(optarg ? optarg : "/dev/ttyUSB0");
3c78c1
 			break;
3c78c1
+		case 'h':
3c78c1
 		case 'r':		/* html report */
3c78c1
 			reporttype = REPORT_HTML;
3c78c1
 			snprintf(filename, sizeof(filename), "%s", optarg ? optarg : "powertop.html");
3c78c1
@@ -480,6 +483,10 @@ int main(int argc, char **argv)
3c78c1
 				exit(1);
3c78c1
 			}
3c78c1
 			break;
3c78c1
+		case 'd':		/* plain text report (dump) */
3c78c1
+			reporttype = REPORT_PLAIN;
3c78c1
+			snprintf(filename, sizeof(filename), "%s", optarg ? optarg : "-");
3c78c1
+			break;
3c78c1
 		case 'i':
3c78c1
 			iterations = (optarg ? atoi(optarg) : 1);
3c78c1
 			break;
3c78c1
@@ -500,7 +507,7 @@ int main(int argc, char **argv)
3c78c1
 			print_version();
3c78c1
 			exit(0);
3c78c1
 			break;
3c78c1
-		case 'h':
3c78c1
+		case 'u':
3c78c1
 			print_usage();
3c78c1
 			exit(0);
3c78c1
 			break;
3c78c1
diff --git a/src/report/report-formatter-plain.cpp b/src/report/report-formatter-plain.cpp
3c78c1
new file mode 100644
3c78c1
index 0000000..9a0d636
3c78c1
--- /dev/null
3c78c1
+++ b/src/report/report-formatter-plain.cpp
3c78c1
@@ -0,0 +1,133 @@
3c78c1
+/* Copyright (c) 2016-2018 Jaroslav Škarvada <jskarvad@redhat.com>
3c78c1
+ * Based on CSV formatter code by Igor Zhbanov <i.zhbanov@samsung.com>
3c78c1
+ *
3c78c1
+ * This file is part of PowerTOP
3c78c1
+ *
3c78c1
+ * This program file is free software; you can redistribute it and/or modify it
3c78c1
+ * under the terms of the GNU General Public License as published by the
3c78c1
+ * Free Software Foundation; version 2 of the License.
3c78c1
+ *
3c78c1
+ * This program is distributed in the hope that it will be useful, but WITHOUT
3c78c1
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3c78c1
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3c78c1
+ * for more details.
3c78c1
+ *
3c78c1
+ * You should have received a copy of the GNU General Public License
3c78c1
+ * along with this program in a file named COPYING; if not, write to the
3c78c1
+ * Free Software Foundation, Inc,
3c78c1
+ * 51 Franklin Street, Fifth Floor,
3c78c1
+ * Boston, MA 02110-1301 USA
3c78c1
+ * or just google for it.
3c78c1
+ */
3c78c1
+
3c78c1
+#define _BSD_SOURCE
3c78c1
+
3c78c1
+/* Uncomment to disable asserts */
3c78c1
+/*#define NDEBUG*/
3c78c1
+
3c78c1
+#include <stdio.h>
3c78c1
+#include <assert.h>
3c78c1
+#include <stdarg.h>
3c78c1
+
3c78c1
+#include "report-formatter-plain.h"
3c78c1
+#include "report-data-html.h"
3c78c1
+
3c78c1
+/* ************************************************************************ */
3c78c1
+report_formatter_plain::report_formatter_plain()
3c78c1
+{
3c78c1
+	/* Do nothing special  */
3c78c1
+}
3c78c1
+
3c78c1
+/* ************************************************************************ */
3c78c1
+void report_formatter_plain::finish_report()
3c78c1
+{
3c78c1
+	/* Do nothing special */
3c78c1
+}
3c78c1
+
3c78c1
+string report_formatter_plain::escape_string(const char *str)
3c78c1
+{
3c78c1
+	assert(str);
3c78c1
+	return string(str);
3c78c1
+}
3c78c1
+
3c78c1
+/* Report Style */
3c78c1
+void report_formatter_plain::add_header()
3c78c1
+{
3c78c1
+}
3c78c1
+
3c78c1
+void
3c78c1
+report_formatter_plain::end_header()
3c78c1
+{
3c78c1
+	/* Do nothing */
3c78c1
+}
3c78c1
+
3c78c1
+void
3c78c1
+report_formatter_plain::add_logo()
3c78c1
+{
3c78c1
+	add_exact("===PowerTOP Report===\n");
3c78c1
+}
3c78c1
+
3c78c1
+
3c78c1
+void
3c78c1
+report_formatter_plain::add_div(struct tag_attr * div_attr)
3c78c1
+{
3c78c1
+	add_exact("\n");
3c78c1
+}
3c78c1
+
3c78c1
+void
3c78c1
+report_formatter_plain::end_div()
3c78c1
+{
3c78c1
+	/*Do nothing*/
3c78c1
+}
3c78c1
+
3c78c1
+void
3c78c1
+report_formatter_plain::add_title(struct tag_attr *title_att, const char *title)
3c78c1
+{
3c78c1
+	addf_exact("==%s==\n", title);
3c78c1
+}
3c78c1
+
3c78c1
+void
3c78c1
+report_formatter_plain::add_navigation()
3c78c1
+{
3c78c1
+	/* No nav in plain - thinking on table of contents */
3c78c1
+}
3c78c1
+
3c78c1
+void
3c78c1
+report_formatter_plain::add_summary_list(string *list, int size)
3c78c1
+{
3c78c1
+	int i;
3c78c1
+	add_exact("\n");
3c78c1
+	for (i=0; i < size; i+=2){
3c78c1
+		addf_exact("%s %s", list[i].c_str(), list[i+1].c_str());
3c78c1
+		if(i < (size - 1))
3c78c1
+			add_exact(" ");
3c78c1
+	}
3c78c1
+	add_exact("\n");
3c78c1
+}
3c78c1
+
3c78c1
+void
3c78c1
+report_formatter_plain::add_table(string *system_data, struct table_attributes* tb_attr)
3c78c1
+{
3c78c1
+	int i, j;
3c78c1
+	int offset=0;
3c78c1
+	string tmp_str="";
3c78c1
+	int empty_row=0;
3c78c1
+	add_exact("\n");
3c78c1
+	for (i=0; i < tb_attr->rows; i++){
3c78c1
+		for (j=0; j < tb_attr->cols; j++){
3c78c1
+			offset = i * (tb_attr->cols) + j;
3c78c1
+			tmp_str=system_data[offset];
3c78c1
+
3c78c1
+			if(tmp_str == " ")
3c78c1
+				empty_row+=1;
3c78c1
+			else{
3c78c1
+				addf_exact("%s", system_data[offset].c_str());
3c78c1
+				if(j < (tb_attr->cols - 1))
3c78c1
+					add_exact(" ");
3c78c1
+			}
3c78c1
+		}
3c78c1
+		if(empty_row < tb_attr->cols)
3c78c1
+		add_exact("\n");
3c78c1
+		empty_row=0;
3c78c1
+	}
3c78c1
+}
3c78c1
diff --git a/src/report/report-formatter-plain.h b/src/report/report-formatter-plain.h
3c78c1
new file mode 100644
3c78c1
index 0000000..276b5ac
3c78c1
--- /dev/null
3c78c1
+++ b/src/report/report-formatter-plain.h
3c78c1
@@ -0,0 +1,54 @@
3c78c1
+/* Copyright (c) 2016-2018 Jaroslav Škarvada <jskarvad@redhat.com>
3c78c1
+ * Based on CSV formatter code by Igor Zhbanov <i.zhbanov@samsung.com>
3c78c1
+ *
3c78c1
+ * This file is part of PowerTOP
3c78c1
+ *
3c78c1
+ * This program file is free software; you can redistribute it and/or modify it
3c78c1
+ * under the terms of the GNU General Public License as published by the
3c78c1
+ * Free Software Foundation; version 2 of the License.
3c78c1
+ *
3c78c1
+ * This program is distributed in the hope that it will be useful, but WITHOUT
3c78c1
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3c78c1
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3c78c1
+ * for more details.
3c78c1
+ *
3c78c1
+ * You should have received a copy of the GNU General Public License
3c78c1
+ * along with this program in a file named COPYING; if not, write to the
3c78c1
+ * Free Software Foundation, Inc,
3c78c1
+ * 51 Franklin Street, Fifth Floor,
3c78c1
+ * Boston, MA 02110-1301 USA
3c78c1
+ * or just google for it.
3c78c1
+ */
3c78c1
+
3c78c1
+#ifndef _REPORT_FORMATTER_PLAIN_H_
3c78c1
+#define _REPORT_FORMATTER_PLAIN_H_
3c78c1
+
3c78c1
+#include <string>
3c78c1
+
3c78c1
+#include "report-formatter-base.h"
3c78c1
+
3c78c1
+class report_formatter_plain: public report_formatter_string_base
3c78c1
+{
3c78c1
+public:
3c78c1
+	report_formatter_plain();
3c78c1
+	void finish_report();
3c78c1
+
3c78c1
+	/* Report Style */
3c78c1
+	void add_logo();
3c78c1
+	void add_header();
3c78c1
+	void end_header();
3c78c1
+	void add_div(struct tag_attr *div_attr);
3c78c1
+	void end_div();
3c78c1
+	void add_title(struct tag_attr *title_att, const char *title);
3c78c1
+	void add_navigation();
3c78c1
+	void add_summary_list(string *list, int size);
3c78c1
+	void add_table(string *system_data, struct table_attributes *tb_attr);
3c78c1
+
3c78c1
+private:
3c78c1
+	void add_quotes();
3c78c1
+	string escape_string(const char *str);
3c78c1
+	bool csv_need_quotes;
3c78c1
+	size_t text_start;
3c78c1
+};
3c78c1
+
3c78c1
+#endif /* _REPORT_FORMATTER_PLAIN_H_ */
3c78c1
diff --git a/src/report/report-maker.cpp b/src/report/report-maker.cpp
3c78c1
index 4049a54..4d0932a 100644
3c78c1
--- a/src/report/report-maker.cpp
3c78c1
+++ b/src/report/report-maker.cpp
3c78c1
@@ -32,6 +32,7 @@
3c78c1
 #include "report-maker.h"
3c78c1
 #include "report-formatter-csv.h"
3c78c1
 #include "report-formatter-html.h"
3c78c1
+#include "report-formatter-plain.h"
3c78c1
 
3c78c1
 /* ************************************************************************ */
3c78c1
 
3c78c1
@@ -103,6 +104,8 @@ report_maker::setup_report_formatter()
3c78c1
 		formatter = new report_formatter_html();
3c78c1
 	else if (type == REPORT_CSV)
3c78c1
 		formatter = new report_formatter_csv();
3c78c1
+	else if (type == REPORT_PLAIN)
3c78c1
+		formatter = new report_formatter_plain();
3c78c1
 	else if (type == REPORT_OFF)
3c78c1
 		formatter = new report_formatter();
3c78c1
 	else
3c78c1
diff --git a/src/report/report-maker.h b/src/report/report-maker.h
3c78c1
index bda4cef..08d2a6d 100644
3c78c1
--- a/src/report/report-maker.h
3c78c1
+++ b/src/report/report-maker.h
3c78c1
@@ -65,7 +65,7 @@ using namespace std;
3c78c1
 /* Conditional gettext. We need original strings for CSV. */
3c78c1
 #ifdef ENABLE_NLS
3c78c1
 #define __(STRING) \
3c78c1
-	((report.get_type() == REPORT_CSV) ? (STRING) : gettext(STRING))
3c78c1
+	((report.get_type() == REPORT_CSV || report.get_type() == REPORT_PLAIN) ? (STRING) : gettext(STRING))
3c78c1
 #else
3c78c1
 #define __(STRING) (STRING)
3c78c1
 #endif
3c78c1
@@ -79,7 +79,8 @@ using namespace std;
3c78c1
 enum report_type {
3c78c1
 	REPORT_OFF,
3c78c1
 	REPORT_HTML,
3c78c1
-	REPORT_CSV
3c78c1
+	REPORT_CSV,
3c78c1
+	REPORT_PLAIN
3c78c1
 };
3c78c1
 
3c78c1
 /* ************************************************************************ */
3c78c1
diff --git a/src/report/report.cpp b/src/report/report.cpp
3c78c1
index f0f31ee..5fa9051 100644
3c78c1
--- a/src/report/report.cpp
3c78c1
+++ b/src/report/report.cpp
3c78c1
@@ -172,30 +172,37 @@ void init_report_output(char *filename_str, int iterations)
3c78c1
 	string filename;
3c78c1
 	time_t stamp;
3c78c1
 	char datestr[200];
3c78c1
+	int len;
3c78c1
 
3c78c1
-	if (iterations == 1)
3c78c1
-		snprintf(reportout.filename, sizeof(reportout.filename), "%s", filename_str);
3c78c1
+	len = strlen(filename_str);
3c78c1
+	if (!len || (len == 1 && filename_str[0] == '-'))
3c78c1
+		reportout.report_file = stdout;
3c78c1
 	else
3c78c1
 	{
3c78c1
-		filename = string(filename_str);
3c78c1
-		period = filename.find_last_of(".");
3c78c1
-		if (period > filename.length())
3c78c1
-			period = filename.length();
3c78c1
-		memset(&datestr, 0, 200);
3c78c1
-		memset(&stamp, 0, sizeof(time_t));
3c78c1
-		stamp = time(NULL);
3c78c1
-		strftime(datestr, sizeof(datestr), "%Y%m%d-%H%M%S", localtime(&stamp));
3c78c1
-		snprintf(reportout.filename, sizeof(reportout.filename), "%s-%s%s",
3c78c1
-			filename.substr(0, period).c_str(), datestr,
3c78c1
-			filename.substr(period).c_str());
3c78c1
-	}
3c78c1
+		if (iterations == 1)
3c78c1
+			snprintf(reportout.filename, sizeof(reportout.filename), "%s", filename_str);
3c78c1
+		else
3c78c1
+		{
3c78c1
+			filename = string(filename_str);
3c78c1
+			period = filename.find_last_of(".");
3c78c1
+			if (period > filename.length())
3c78c1
+				period = filename.length();
3c78c1
+			memset(&datestr, 0, 200);
3c78c1
+			memset(&stamp, 0, sizeof(time_t));
3c78c1
+			stamp = time(NULL);
3c78c1
+			strftime(datestr, sizeof(datestr), "%Y%m%d-%H%M%S", localtime(&stamp));
3c78c1
+			snprintf(reportout.filename, sizeof(reportout.filename), "%s-%s%s",
3c78c1
+				filename.substr(0, period).c_str(), datestr,
3c78c1
+				filename.substr(period).c_str());
3c78c1
+		}
3c78c1
 	
3c78c1
-	reportout.report_file = fopen(reportout.filename, "wm");
3c78c1
-	if (!reportout.report_file) {
3c78c1
-		fprintf(stderr, _("Cannot open output file %s (%s)\n"),
3c78c1
-			reportout.filename, strerror(errno));
3c78c1
+		reportout.report_file = fopen(reportout.filename, "wm");
3c78c1
+		if (!reportout.report_file) {
3c78c1
+			fprintf(stderr, _("Cannot open output file %s (%s)\n"),
3c78c1
+				reportout.filename, strerror(errno));
3c78c1
+		}
3c78c1
 	}
3c78c1
-
3c78c1
+    
3c78c1
 	report.set_type(reporttype);
3c78c1
 	system_info();
3c78c1
 }
3c78c1
@@ -208,10 +215,14 @@ void finish_report_output(void)
3c78c1
 	report.finish_report();
3c78c1
 	if (reportout.report_file)
3c78c1
 	{
3c78c1
-		fprintf(stderr, _("PowerTOP outputing using base filename %s\n"), reportout.filename);
3c78c1
+		if (reportout.report_file == stdout)
3c78c1
+			fprintf(stderr, _("PowerTOP outputing using standard output\n"));
3c78c1
+		else
3c78c1
+			fprintf(stderr, _("PowerTOP outputing using base filename %s\n"), reportout.filename);
3c78c1
 		fputs(report.get_result(), reportout.report_file);
3c78c1
 		fdatasync(fileno(reportout.report_file));
3c78c1
-		fclose(reportout.report_file);
3c78c1
+		if (reportout.report_file != stdout)
3c78c1
+			fclose(reportout.report_file);
3c78c1
 	}
3c78c1
 	report.clear_result();
3c78c1
 }
3c78c1
-- 
3c78c1
2.14.3
3c78c1