summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Lebon <jlebon@redhat.com>2018-01-10 17:51:56 +0000
committerJonathan Lebon <jlebon@redhat.com>2018-01-10 17:58:14 +0000
commit6f1ee5db1400b13a9a0fa0b2274ae34e8710c1aa (patch)
tree07f5e7961b4be1ecbf160c2565fa09a2a34d2c4d
parent96b1fd9578b3d6ff2d8e0707068f5ef450eba98c (diff)
downloadlibglnx-6f1ee5db1400b13a9a0fa0b2274ae34e8710c1aa.tar.gz
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.
-rw-r--r--glnx-console.c10
-rw-r--r--glnx-console.h2
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);