diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-28 15:15:12 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-29 09:18:04 +0200 |
commit | f1d4e0fb637bd9c3f5ad72c22cb5a716c3e669c8 (patch) | |
tree | e2b27146ac7433b201e39aff92d15a88407bcc7b /cli/mmcli-modem.c | |
parent | 422ed7b63331d1cbf8f58dcc694404bbb8b4a335 (diff) |
mmcli: prefix all NMEA traces in order to get a pretty print
Diffstat (limited to 'cli/mmcli-modem.c')
-rw-r--r-- | cli/mmcli-modem.c | 42 |
1 files changed, 2 insertions, 40 deletions
diff --git a/cli/mmcli-modem.c b/cli/mmcli-modem.c index c960ec06..f58ec39f 100644 --- a/cli/mmcli-modem.c +++ b/cli/mmcli-modem.c @@ -23,7 +23,6 @@ #include <stdio.h> #include <stdlib.h> #include <locale.h> -#include <string.h> #include <glib.h> #include <gio/gio.h> @@ -216,43 +215,6 @@ cancelled (GCancellable *cancellable) mmcli_async_operation_done (); } -static gchar * -prefix_newlines (const gchar *prefix, - const gchar *str) -{ - GString *prefixed_string = NULL; - const gchar *line_start = str; - const gchar *line_end; - - while ((line_end = strchr (line_start, '\n'))) { - gssize line_length; - - line_length = line_end - line_start; - if (line_start[line_length - 1] == '\r') - line_length--; - - if (line_length > 0) { - if (prefixed_string) { - /* If not the first line, add the prefix */ - g_string_append_printf (prefixed_string, - "\n%s", prefix); - } else { - prefixed_string = g_string_new (""); - } - - g_string_append_len (prefixed_string, - line_start, - line_length); - } - - line_start = line_end + 1; - } - - return (prefixed_string ? - g_string_free (prefixed_string, FALSE) : - NULL); -} - static void print_bearer_short_info (MMBearer *bearer) { @@ -316,8 +278,8 @@ print_modem_info (void) own_numbers_string = NULL; /* Rework possible multiline strings */ - prefixed_revision = prefix_newlines (" | ", - mm_modem_get_revision (ctx->modem)); + prefixed_revision = mmcli_prefix_newlines (" | ", + mm_modem_get_revision (ctx->modem)); /* Global IDs */ g_print ("\n" |