]> granicus.if.org Git - sysstat/commitdiff
Move xprintf()/xprintf0() functions from sadf.c to common.c
authorSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 19 Aug 2016 13:32:33 +0000 (15:32 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 19 Aug 2016 13:32:33 +0000 (15:32 +0200)
These functions will be used by other sysstat commands (eg. iostat). So
put them in common.c.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
common.c
common.h
sadf.c
sadf.h

index 865dd9422b6761f44c5a15d0ae3b05ada337b88b..4d3fb3efdd0445b823f6a47ec62acacdb81f8c66 100644 (file)
--- a/common.c
+++ b/common.c
@@ -348,6 +348,69 @@ int is_iso_time_fmt(void)
        return is_iso;
 }
 
+/*
+ ***************************************************************************
+ * Print tabulations
+ *
+ * IN:
+ * @nr_tab     Number of tabs to print.
+ ***************************************************************************
+ */
+void prtab(int nr_tab)
+{
+       int i;
+
+       for (i = 0; i < nr_tab; i++) {
+               printf("\t");
+       }
+}
+
+/*
+ ***************************************************************************
+ * printf() function modified for XML-like output. Don't print a CR at the
+ * end of the line.
+ *
+ * IN:
+ * @nr_tab     Number of tabs to print.
+ * @fmtf       printf() format.
+ ***************************************************************************
+ */
+void xprintf0(int nr_tab, const char *fmtf, ...)
+{
+       static char buf[1024];
+       va_list args;
+
+       va_start(args, fmtf);
+       vsnprintf(buf, sizeof(buf), fmtf, args);
+       va_end(args);
+
+       prtab(nr_tab);
+       printf("%s", buf);
+}
+
+/*
+ ***************************************************************************
+ * printf() function modified for XML-like output. Print a CR at the end of
+ * the line.
+ *
+ * IN:
+ * @nr_tab     Number of tabs to print.
+ * @fmtf       printf() format.
+ ***************************************************************************
+ */
+void xprintf(int nr_tab, const char *fmtf, ...)
+{
+       static char buf[1024];
+       va_list args;
+
+       va_start(args, fmtf);
+       vsnprintf(buf, sizeof(buf), fmtf, args);
+       va_end(args);
+
+       prtab(nr_tab);
+       printf("%s\n", buf);
+}
+
 /*
  ***************************************************************************
  * Print banner.
index dd4773ed427263a09cabe945d0f65cc35484eda7..22612c864428041bdda451997e95d331791a1630 100644 (file)
--- a/common.h
+++ b/common.h
@@ -272,5 +272,9 @@ char *strtolower
        (char *);
 void sysstat_panic
        (const char *, int);
+void xprintf
+       (int, const char *, ...);
+void xprintf0
+       (int, const char *, ...);
 
 #endif  /* _COMMON_H */
diff --git a/sadf.c b/sadf.c
index 0939cd90488bca0f0aa2d5449928c8305b911c44..85e749872c51bd104bab21bf3babd9ef25c0b9d8 100644 (file)
--- a/sadf.c
+++ b/sadf.c
@@ -181,69 +181,6 @@ void check_format_options(void)
        }
 }
 
-/*
- ***************************************************************************
- * Print tabulations
- *
- * IN:
- * @nr_tab     Number of tabs to print.
- ***************************************************************************
- */
-void prtab(int nr_tab)
-{
-       int i;
-
-       for (i = 0; i < nr_tab; i++) {
-               printf("\t");
-       }
-}
-
-/*
- ***************************************************************************
- * printf() function modified for logic #1 (XML-like) display. Don't print a
- * CR at the end of the line.
- *
- * IN:
- * @nr_tab     Number of tabs to print.
- * @fmtf       printf() format.
- ***************************************************************************
- */
-void xprintf0(int nr_tab, const char *fmtf, ...)
-{
-       static char buf[1024];
-       va_list args;
-
-       va_start(args, fmtf);
-       vsnprintf(buf, sizeof(buf), fmtf, args);
-       va_end(args);
-
-       prtab(nr_tab);
-       printf("%s", buf);
-}
-
-/*
- ***************************************************************************
- * printf() function modified for logic #1 (XML-like) display. Print a CR
- * at the end of the line.
- *
- * IN:
- * @nr_tab     Number of tabs to print.
- * @fmtf       printf() format.
- ***************************************************************************
- */
-void xprintf(int nr_tab, const char *fmtf, ...)
-{
-       static char buf[1024];
-       va_list args;
-
-       va_start(args, fmtf);
-       vsnprintf(buf, sizeof(buf), fmtf, args);
-       va_end(args);
-
-       prtab(nr_tab);
-       printf("%s\n", buf);
-}
-
 /*
  ***************************************************************************
  * Save or restore number of items for all known activities.
diff --git a/sadf.h b/sadf.h
index ddb6a2485e1c27ecfc165e3ae3580cd110c05be9..5f3a82fea9e9fed8e64a4cd212c7002ed207e2f6 100644 (file)
--- a/sadf.h
+++ b/sadf.h
 
 void convert_file
        (char [], struct activity *[]);
-void xprintf
-       (int, const char *, ...);
-void xprintf0
-       (int, const char *, ...);
 
 /*
  * Prototypes used to display restart messages