.f_statistics = NULL,
.f_timestamp = NULL,
.f_restart = NULL,
- .f_comment = NULL
+ .f_comment = NULL,
+ .f_display = NULL
};
/*
*/
struct report_format db_fmt = {
.id = F_DB_OUTPUT,
- .options = FO_GROUPED_STATS + FO_LOCAL_TIME + FO_HORIZONTALLY +
+ .options = FO_LOCAL_TIME + FO_HORIZONTALLY +
FO_SEC_EPOCH + FO_FIELD_LIST,
.f_header = NULL,
.f_statistics = NULL,
.f_timestamp = print_db_timestamp,
.f_restart = print_db_restart,
- .f_comment = print_db_comment
+ .f_comment = print_db_comment,
+ .f_display = logic2_display_loop
};
/*
*/
struct report_format ppc_fmt = {
.id = F_PPC_OUTPUT,
- .options = FO_GROUPED_STATS + FO_LOCAL_TIME + FO_SEC_EPOCH,
+ .options = FO_LOCAL_TIME + FO_SEC_EPOCH,
.f_header = NULL,
.f_statistics = NULL,
.f_timestamp = print_ppc_timestamp,
.f_restart = print_ppc_restart,
- .f_comment = print_ppc_comment
+ .f_comment = print_ppc_comment,
+ .f_display = logic2_display_loop
};
/*
.f_statistics = print_xml_statistics,
.f_timestamp = print_xml_timestamp,
.f_restart = print_xml_restart,
- .f_comment = print_xml_comment
+ .f_comment = print_xml_comment,
+ .f_display = logic1_display_loop
};
/*
.f_statistics = print_json_statistics,
.f_timestamp = print_json_timestamp,
.f_restart = print_json_restart,
- .f_comment = print_json_comment
+ .f_comment = print_json_comment,
+ .f_display = logic1_display_loop
};
/*
.f_statistics = NULL,
.f_timestamp = NULL,
.f_restart = NULL,
- .f_comment = NULL
+ .f_comment = NULL,
+ .f_display = NULL
};
/*
.f_statistics = NULL,
.f_timestamp = NULL,
.f_restart = NULL,
- .f_comment = NULL
+ .f_comment = NULL,
+ .f_display = svg_display_loop
};
/*
*/
struct report_format raw_fmt = {
.id = F_RAW_OUTPUT,
- .options = FO_GROUPED_STATS + FO_LOCAL_TIME + FO_SEC_EPOCH,
+ .options = FO_LOCAL_TIME + FO_SEC_EPOCH,
.f_header = NULL,
.f_statistics = NULL,
.f_timestamp = print_raw_timestamp,
.f_restart = print_raw_restart,
- .f_comment = print_raw_comment
+ .f_comment = print_raw_comment,
+ .f_display = logic2_display_loop
};
/*
.f_statistics = print_pcp_statistics,
.f_timestamp = print_pcp_timestamp,
.f_restart = NULL,
- .f_comment = NULL
+ .f_comment = NULL,
+ .f_display = logic1_display_loop
};
/*
* Logic #1: Grouped by record type. Sorted by timestamp.
* Formats: XML, JSON, PCP
*
+ * NB: all statistics data will be sorted by timestamp.
+ * Example: If stats for activities A and B at time t and t' have been collected,
+ * the output will be:
+ * stats for activity A at t
+ * stats for activity B at t
+ * stats for activity A at t'
+ * stats for activity B at t'
+ *
* IN:
* @ifd File descriptor of input file.
- * @file_actlst List of (known or unknown) activities in file.
* @file System activity data file name (name of file being read).
- * @pcparchive PCP archive file name.
+ * @file_actlst List of (known or unknown) activities in file.
* @file_magic System activity file magic header.
* @rectime Structure where timestamp (expressed in local time or in UTC
* depending on whether options -T/-t have been used or not) can
* be saved for current record.
* @loctime Structure where timestamp (expressed in local time) can be
* saved for current record.
+ * @dparm PCP archive file name.
***************************************************************************
*/
-void logic1_display_loop(int ifd, struct file_activity *file_actlst, char *file,
- char *pcparchive, struct file_magic *file_magic,
- struct tm *rectime, struct tm *loctime)
+void logic1_display_loop(int ifd, char *file, struct file_activity *file_actlst,
+ struct file_magic *file_magic, struct tm *rectime,
+ struct tm *loctime, void *dparm)
{
int curr, rtype, tab = 0;
int eosaf, next, reset = FALSE;
long cnt = 1;
+ char *pcparchive = (char *) dparm;
if (format == F_JSON_OUTPUT) {
/* Use a decimal point to make JSON code compliant with RFC7159 */
* records.
* Formats: ppc, CSV, raw
*
+ * NB: All statistics data for one activity will be displayed before
+ * displaying stats for next activity. This is what sar does in its report.
+ * Example: If stats for activities A and B at time t and t' have been collected,
+ * the output will be:
+ * stats for activity A at t
+ * stats for activity A at t'
+ * stats for activity B at t
+ * stats for activity B at t'
+ *
* IN:
* @ifd File descriptor of input file.
+ * @file Name of file being read.
* @file_actlst List of (known or unknown) activities in file.
+ * @file_magic file_magic structure filled with file magic header data.
* @rectime Structure where timestamp (expressed in local time or in UTC
* depending on whether options -T/-t have been used or not) can
* be saved for current record.
* @loctime Structure where timestamp (expressed in local time) can be
* saved for current record.
- * @file Name of file being read.
- * @file_magic file_magic structure filled with file magic header data.
+ * @dparm Unused here.
***************************************************************************
*/
-void logic2_display_loop(int ifd, struct file_activity *file_actlst,
- struct tm *rectime, struct tm *loctime, char *file,
- struct file_magic *file_magic)
+void logic2_display_loop(int ifd, char *file, struct file_activity *file_actlst,
+ struct file_magic *file_magic, struct tm *rectime,
+ struct tm *loctime, void *dparm)
{
int i, p;
int curr = 1, rtype;
/*
***************************************************************************
- * Display file contents in selected format (logic #3).
- * Logic #3: Special logic for SVG output format.
- * Formats: SVG
+ * Display file contents in SVG format.
*
* IN:
* @ifd File descriptor of input file.
+ * @file Name of file being read.
* @file_actlst List of (known or unknown) activities in file.
+ * @file_magic file_magic structure filled with file magic header data.
* @rectime Structure where timestamp (expressed in local time or in UTC
* depending on whether options -T/-t have been used or not) can
* be saved for current record.
* @loctime Structure where timestamp (expressed in local time) can be
* saved for current record.
- * @file Name of file being read.
- * @file_magic file_magic structure filled with file magic header data.
+ * @dparm Unused here.
***************************************************************************
*/
-void logic3_display_loop(int ifd, struct file_activity *file_actlst,
- struct tm *rectime, struct tm *loctime, char *file,
- struct file_magic *file_magic)
+void svg_display_loop(int ifd, char *file, struct file_activity *file_actlst,
+ struct file_magic *file_magic, struct tm *rectime,
+ struct tm *loctime, void *dparm)
{
struct svg_hdr_parm parm;
int i, p;
allocate_structures(act);
/* Call function corresponding to selected output format */
- if (format == F_SVG_OUTPUT) {
- logic3_display_loop(ifd, file_actlst,
- &rectime, &loctime, dfile, &file_magic);
- }
- else if (DISPLAY_GROUPED_STATS(fmt[f_position]->options)) {
- logic2_display_loop(ifd, file_actlst,
- &rectime, &loctime, dfile, &file_magic);
- }
- else {
- logic1_display_loop(ifd, file_actlst, dfile, pcparchive,
- &file_magic, &rectime, &loctime);
+ if (*fmt[f_position]->f_display) {
+ (*fmt[f_position]->f_display)(ifd, dfile, file_actlst, &file_magic,
+ &rectime, &loctime, pcparchive);
}
close(ifd);
/* Format options */
-/*
- * Indicate that all statistics data for one activity should be displayed before
- * displaying stats for next activity. This is what sar does in its report.
- * Example: If stats for activities A and B at time t and t' have been collected,
- * setting AO_GROUPED_STATS for a format will result in the following output:
- * stats for activity A at t
- * stats for activity A at t'
- * stats for activity B at t
- * stats for activity B at t'
- * Without this option, output would be:
- * stats for activity A at t
- * stats for activity B at t
- * stats for activity A at t'
- * stats for activity B at t'
- */
-#define FO_GROUPED_STATS 0x01
+/* Unused 0x01 */
/*
* Indicate that output should stop after the header is displayed.
*/
#define FO_NO_TRUE_TIME 0x100
-#define DISPLAY_GROUPED_STATS(m) (((m) & FO_GROUPED_STATS) == FO_GROUPED_STATS)
#define ACCEPT_HEADER_ONLY(m) (((m) & FO_HEADER_ONLY) == FO_HEADER_ONLY)
#define ACCEPT_BAD_FILE_FORMAT(m) (((m) & FO_BAD_FILE_FORMAT) == FO_BAD_FILE_FORMAT)
#define ACCEPT_LOCAL_TIME(m) (((m) & FO_LOCAL_TIME) == FO_LOCAL_TIME)
(void *, int, char *, struct file_magic *, struct file_header *,
struct activity * [], unsigned int [], struct file_activity *);
+/*
+ * Main display functions
+ */
+void logic1_display_loop
+ (int, char *, struct file_activity *, struct file_magic *,
+ struct tm *, struct tm *, void *);
+void logic2_display_loop
+ (int, char *, struct file_activity *, struct file_magic *,
+ struct tm *, struct tm *, void *);
+void svg_display_loop
+ (int, char *, struct file_activity *, struct file_magic *,
+ struct tm *, struct tm *, void *);
+
#endif /* _SADF_H */