From: Greg Kroah-Hartman Date: Tue, 3 Mar 2009 16:44:54 +0000 (-0800) Subject: Change the formatting of --action output X-Git-Url: https://git.toastfreeware.priv.at/gregoa/bti.git/commitdiff_plain/f66ed0bdb6f8c7cb2347df19dc4843a4253540f9?ds=sidebyside Change the formatting of --action output Now it is: [username] message instead of: message [username] which makes it a bit easier to read and parse --- diff --git a/bti.c b/bti.c index 2a94236..abf436c 100644 --- a/bti.c +++ b/bti.c @@ -175,31 +175,34 @@ static CURL *curl_init(void) void parse_statuses(xmlDocPtr doc, xmlNodePtr current) { - xmlChar *text; - xmlChar *user; + xmlChar *text = NULL; + xmlChar *user = NULL; xmlNodePtr userinfo; + 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); - 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 (user) + xmlFree(user); user = xmlNodeListGetString(doc, userinfo->xmlChildrenNode, 1); - printf(" [%s]\n", user); - xmlFree(user); } - userinfo = userinfo->next; } } + if (user && text) { + printf("[%s] %s\n", user, text); + xmlFree(user); + xmlFree(text); + user = NULL; + text = NULL; + } } - current = current->next; }