Mercurial > hg
comparison mcabber/src/jabglue.c @ 862:5ed97fc7afa0
Strip trailing empty lines from error messages
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 21 May 2006 09:49:43 +0200 |
parents | e1adea19ba14 |
children | a7b3409df6bc |
comparison
equal
deleted
inserted
replaced
861:e1adea19ba14 | 862:5ed97fc7afa0 |
---|---|
854 // Display the error to the user | 854 // Display the error to the user |
855 // x: error tag xmlnode pointer | 855 // x: error tag xmlnode pointer |
856 void display_server_error(xmlnode x) | 856 void display_server_error(xmlnode x) |
857 { | 857 { |
858 const char *desc = NULL; | 858 const char *desc = NULL; |
859 char *sdesc; | |
859 int code = 0; | 860 int code = 0; |
860 char *s; | 861 char *s; |
861 const char *p; | 862 const char *p; |
862 | 863 |
863 /* RFC3920: | 864 /* RFC3920: |
883 | 884 |
884 // And sometimes there is a text message | 885 // And sometimes there is a text message |
885 s = xmlnode_get_tag_data(x, "text"); | 886 s = xmlnode_get_tag_data(x, "text"); |
886 if (s && *s) desc = s; | 887 if (s && *s) desc = s; |
887 | 888 |
888 scr_LogPrint(LPRINT_LOGNORM, "Error code from server: %d %s", code, desc); | 889 // Strip trailing newlines |
890 sdesc = g_strdup(desc); | |
891 for (s = sdesc; *s; s++) ; | |
892 if (s > sdesc) | |
893 s--; | |
894 while (s >= sdesc && (*s == '\n' || *s == '\r')) | |
895 *s-- = '\0'; | |
896 | |
897 scr_LogPrint(LPRINT_LOGNORM, "Error code from server: %d %s", code, sdesc); | |
898 g_free(sdesc); | |
889 } | 899 } |
890 | 900 |
891 static void statehandler(jconn conn, int state) | 901 static void statehandler(jconn conn, int state) |
892 { | 902 { |
893 static int previous_state = -1; | 903 static int previous_state = -1; |