Change the formatting of --action output
authorGreg Kroah-Hartman <gregkh@suse.de>
Tue, 3 Mar 2009 16:44:54 +0000 (08:44 -0800)
committerAmir Mohammad Saied <amirsaied@gmail.com>
Wed, 4 Mar 2009 06:44:16 +0000 (10:14 +0330)
Now it is:
[username] message
instead of:
message [username]
which makes it a bit easier to read and parse

bti.c

diff --git a/bti.c b/bti.c
index 2a94236..abf436c 100644 (file)
--- a/bti.c
+++ b/bti.c
@@ -175,31 +175,34 @@ static CURL *curl_init(void)
 
 void parse_statuses(xmlDocPtr doc, xmlNodePtr current)
 {
 
 void parse_statuses(xmlDocPtr doc, xmlNodePtr current)
 {
-       xmlChar *text;
-       xmlChar *user;
+       xmlChar *text = NULL;
+       xmlChar *user = NULL;
        xmlNodePtr userinfo;
        xmlNodePtr userinfo;
+
        current = current->xmlChildrenNode;
        while (current != NULL) {
                if (current->type == XML_ELEMENT_NODE) {
        current = current->xmlChildrenNode;
        while (current != NULL) {
                if (current->type == XML_ELEMENT_NODE) {
-                       if (!xmlStrcmp(current->name, (const xmlChar *)"text")) {
+                       if (!xmlStrcmp(current->name, (const xmlChar *)"text"))
                                text = xmlNodeListGetString(doc, current->xmlChildrenNode, 1);
                                text = xmlNodeListGetString(doc, current->xmlChildrenNode, 1);
-                               printf("%s", text);
-                               xmlFree(text);
-                       }
                        if (!xmlStrcmp(current->name, (const xmlChar *)"user")) {
                                userinfo = current->xmlChildrenNode;
                                while (userinfo != NULL) {
                                        if ((!xmlStrcmp(userinfo->name, (const xmlChar *)"screen_name"))) {
                        if (!xmlStrcmp(current->name, (const xmlChar *)"user")) {
                                userinfo = current->xmlChildrenNode;
                                while (userinfo != NULL) {
                                        if ((!xmlStrcmp(userinfo->name, (const xmlChar *)"screen_name"))) {
+                                               if (user)
+                                                       xmlFree(user);
                                                user = xmlNodeListGetString(doc, userinfo->xmlChildrenNode, 1);
                                                user = xmlNodeListGetString(doc, userinfo->xmlChildrenNode, 1);
-                                               printf(" [%s]\n", user);
-                                               xmlFree(user);
                                        }
                                        }
-
                                        userinfo = userinfo->next;
                                }
                        }
                                        userinfo = userinfo->next;
                                }
                        }
+                       if (user && text) {
+                               printf("[%s] %s\n", user, text);
+                               xmlFree(user);
+                               xmlFree(text);
+                               user = NULL;
+                               text = NULL;
+                       }
                }
                }
-
                current = current->next;
        }
 
                current = current->next;
        }