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

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