move output logic to one function
authorGreg Kroah-Hartman <gregkh@suse.de>
Wed, 12 Jan 2011 22:52:11 +0000 (14:52 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 12 Jan 2011 22:52:11 +0000 (14:52 -0800)
This is in preparation for colored output.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
bti.c

diff --git a/bti.c b/bti.c
index a70443a..3938e0a 100644 (file)
--- a/bti.c
+++ b/bti.c
@@ -283,6 +283,16 @@ static CURL *curl_init(void)
        return curl;
 }
 
+/* The final place data is sent to the screen/pty/tty */
+bti_output_line(struct session *session, xmlChar *user, xmlChar *id,
+               xmlChar *created, xmlChar *text)
+{
+       if (session->verbose)
+               printf("[%s] {%s} (%.16s) %s\n", user, id, created, text);
+       else
+               printf("[%s] %s\n", user, text);
+}
+
 static void parse_statuses(struct session *session,
                           xmlDocPtr doc, xmlNodePtr current)
 {
@@ -314,12 +324,7 @@ static void parse_statuses(struct session *session,
                        }
 
                        if (user && text && created && id) {
-                               if (session->verbose)
-                                       printf("[%s] {%s} (%.16s) %s\n",
-                                               user, id, created, text);
-                               else
-                                       printf("[%s] %s\n",
-                                               user, text);
+                               bti_output_line(session, user, id, created, text);
                                xmlFree(user);
                                xmlFree(text);
                                xmlFree(created);