]> granicus.if.org Git - sysstat/blobdiff - format.c
Use sizeof() instead of hard-coded values with snprintf() function
[sysstat] / format.c
index 1283e5cf25941a04cf955aa7fba95e96f04f9b69..9547f30ed7b52273ae68234271c746e71a2eac6d 100644 (file)
--- a/format.c
+++ b/format.c
@@ -1,6 +1,6 @@
 /*
  * format.c: Output format definitions for sadf and sar
- * (C) 2011-2016 by Sebastien GODARD (sysstat <at> orange.fr)
+ * (C) 2011-2021 by Sebastien GODARD (sysstat <at> orange.fr)
  *
  ***************************************************************************
  * This program is free software; you can redistribute it and/or modify it *
  */
 struct report_format hdr_fmt = {
        .id             = F_HEADER_OUTPUT,
-       .options        = FO_HEADER_ONLY + FO_BAD_FILE_FORMAT,
+       .options        = FO_HEADER_ONLY,
        .f_header       = print_hdr_header,
        .f_statistics   = NULL,
        .f_timestamp    = NULL,
        .f_restart      = NULL,
-       .f_comment      = NULL
+       .f_comment      = NULL,
+       .f_display      = NULL
 };
 
 /*
@@ -53,13 +54,14 @@ struct report_format hdr_fmt = {
  */
 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
 };
 
 /*
@@ -67,12 +69,13 @@ struct report_format db_fmt = {
  */
 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
 };
 
 /*
@@ -85,7 +88,8 @@ struct report_format xml_fmt = {
        .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
 };
 
 /*
@@ -93,12 +97,14 @@ struct report_format xml_fmt = {
  */
 struct report_format json_fmt = {
        .id             = F_JSON_OUTPUT,
-       .options        = FO_HEADER_ONLY + FO_LOCAL_TIME + FO_TEST_MARKUP,
+       .options        = FO_HEADER_ONLY + FO_LOCAL_TIME + FO_TEST_MARKUP +
+                         FO_LC_NUMERIC_C,
        .f_header       = print_json_header,
        .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
 };
 
 /*
@@ -106,12 +112,13 @@ struct report_format json_fmt = {
  */
 struct report_format conv_fmt = {
        .id             = F_CONV_OUTPUT,
-       .options        = FO_BAD_FILE_FORMAT,
+       .options        = 0,
        .f_header       = NULL,
        .f_statistics   = NULL,
        .f_timestamp    = NULL,
        .f_restart      = NULL,
-       .f_comment      = NULL
+       .f_comment      = NULL,
+       .f_display      = NULL
 };
 
 /*
@@ -119,12 +126,43 @@ struct report_format conv_fmt = {
  */
 struct report_format svg_fmt = {
        .id             = F_SVG_OUTPUT,
-       .options        = FO_HEADER_ONLY + FO_LOCAL_TIME + FO_NO_TRUE_TIME,
+       .options        = FO_HEADER_ONLY + FO_LOCAL_TIME + FO_NO_TRUE_TIME +
+                         FO_LC_NUMERIC_C,
        .f_header       = print_svg_header,
        .f_statistics   = NULL,
        .f_timestamp    = NULL,
        .f_restart      = NULL,
-       .f_comment      = NULL
+       .f_comment      = NULL,
+       .f_display      = svg_display_loop
+};
+
+/*
+ * Raw output.
+ */
+struct report_format raw_fmt = {
+       .id             = F_RAW_OUTPUT,
+       .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_display      = logic2_display_loop
+};
+
+/*
+ * PCP output.
+ */
+struct report_format pcp_fmt = {
+       .id             = F_PCP_OUTPUT,
+       .options        = FO_HEADER_ONLY + FO_LOCAL_TIME + FO_NO_TRUE_TIME +
+                         FO_ITEM_LIST + FO_FULL_ORDER,
+       .f_header       = print_pcp_header,
+       .f_statistics   = print_pcp_statistics,
+       .f_timestamp    = print_pcp_timestamp,
+       .f_restart      = print_pcp_restart,
+       .f_comment      = print_pcp_comment,
+       .f_display      = logic1_display_loop
 };
 
 /*
@@ -137,7 +175,9 @@ struct report_format *fmt[NR_FMT] = {
        &xml_fmt,
        &json_fmt,
        &conv_fmt,
-       &svg_fmt
+       &svg_fmt,
+       &raw_fmt,
+       &pcp_fmt
 };
 #endif
 
@@ -148,7 +188,7 @@ struct report_format *fmt[NR_FMT] = {
  * (RESTART and COMMENT) records.
  */
 struct report_format sar_fmt = {
-       .id             = 0,
+       .id             = F_SAR_OUTPUT,
        .options        = 0,
        .f_header       = NULL,
        .f_statistics   = NULL,