[libglnx] console: make stdout_is_tty() public



commit 6f1ee5db1400b13a9a0fa0b2274ae34e8710c1aa
Author: Jonathan Lebon <jlebon redhat com>
Date:   Wed Jan 10 17:51:56 2018 +0000

    console: make stdout_is_tty() public
    
    Share its static var goodness with clients. This will be used in
    rpm-ostree from various places which sometimes do use a `GLnxConsole`
    and sometimes don't, so it's more convenient to make it its own
    function.

 glnx-console.c |   10 +++++-----
 glnx-console.h |    2 ++
 2 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/glnx-console.c b/glnx-console.c
index 1cb3a49..8813074 100644
--- a/glnx-console.c
+++ b/glnx-console.c
@@ -46,8 +46,8 @@
 static gboolean locked;
 static guint64 last_update_ms; /* monotonic time in millis we last updated */
 
-static gboolean
-stdout_is_tty (void)
+gboolean
+glnx_stdout_is_tty (void)
 {
   static gsize initialized = 0;
   static gboolean stdout_is_tty_v;
@@ -156,7 +156,7 @@ glnx_console_lock (GLnxConsoleRef *console)
   g_return_if_fail (!locked);
   g_return_if_fail (!console->locked);
 
-  console->is_tty = stdout_is_tty ();
+  console->is_tty = glnx_stdout_is_tty ();
 
   locked = console->locked = TRUE;
 
@@ -199,7 +199,7 @@ text_percent_internal (const char *text,
   if (percentage != 100)
     {
       const guint64 diff_ms = current_ms - last_update_ms;
-      if (stdout_is_tty ())
+      if (glnx_stdout_is_tty ())
         {
           if (diff_ms < (1000/MAX_TTY_UPDATE_HZ))
             return;
@@ -224,7 +224,7 @@ text_percent_internal (const char *text,
 
   const guint input_textlen = text ? strlen (text) : 0;
 
-  if (!stdout_is_tty ())
+  if (!glnx_stdout_is_tty ())
     {
       if (text)
         fprintf (stdout, "%s", text);
diff --git a/glnx-console.h b/glnx-console.h
index 108dc40..d853a80 100644
--- a/glnx-console.h
+++ b/glnx-console.h
@@ -31,6 +31,8 @@ struct GLnxConsoleRef {
 
 typedef struct GLnxConsoleRef GLnxConsoleRef;
 
+gboolean glnx_stdout_is_tty (void);
+
 void    glnx_console_lock (GLnxConsoleRef *ref);
 
 void    glnx_console_text (const char     *text);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]