comparison main.c @ 430:aaadf6cea6be

Better handling of some messages.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 24 May 2012 14:10:47 +0300
parents 2ac24f1e241b
children a9b20b31cae1
comparison
equal deleted inserted replaced
429:2ac24f1e241b 430:aaadf6cea6be
644 BOOL isMine, isIgnored = FALSE; 644 BOOL isMine, isIgnored = FALSE;
645 char *name, *msg, *t; 645 char *name, *msg, *t;
646 646
647 // Find start of the message 647 // Find start of the message
648 name = conn->ptr; 648 name = conn->ptr;
649 t = nn_conn_buf_strstr(conn, "</USER><MESSAGE>"); 649 t = nn_conn_buf_strstr(conn, "</USER>");
650 if (!t) return 1; 650 if (!t) return 1;
651 *t = 0; 651 *t = 0;
652
653 // Find end of the message
654 t = nn_conn_buf_strstr(conn, "<MESSAGE>");
655 if (!t) return 2;
652 msg = conn->ptr; 656 msg = conn->ptr;
653 657
654 // Find end of the message
655 t = nn_conn_buf_strstr(conn, "</MESSAGE>"); 658 t = nn_conn_buf_strstr(conn, "</MESSAGE>");
656 if (!t) return 3; 659 if (!t) return 3;
657 *t = 0; 660 *t = 0;
658 661
659 // Decode message string 662 // Decode message string
754 char tmpStr[256]; 757 char tmpStr[256];
755 str_get_timestamp(tmpStr, sizeof(tmpStr), "%c"); 758 str_get_timestamp(tmpStr, sizeof(tmpStr), "%c");
756 759
757 if (!nn_conn_buf_strcmp(conn, "FAILURE>")) 760 if (!nn_conn_buf_strcmp(conn, "FAILURE>"))
758 { 761 {
762 nn_conn_buf_strstr(conn, "</LOGIN_FAILURE>");
759 printMsg(NULL, "½1½Login failure½0½ - ½3½%s½0½\n", tmpStr); 763 printMsg(NULL, "½1½Login failure½0½ - ½3½%s½0½\n", tmpStr);
760 return -2; 764 return -2;
761 } 765 }
762 else if (!nn_conn_buf_strcmp(conn, "SUCCESS>")) 766 else if (!nn_conn_buf_strcmp(conn, "SUCCESS>"))
763 { 767 {
768 nn_conn_buf_strstr(conn, "</LOGIN_SUCCESS>");
764 printMsg(NULL, "½2½Login success½0½ - ½3½%s½0½\n", tmpStr); 769 printMsg(NULL, "½2½Login success½0½ - ½3½%s½0½\n", tmpStr);
765 nn_conn_send_msg(conn, optUserNameEnc, "%2FRequestUserList"); 770 nn_conn_send_msg(conn, optUserNameEnc, "%2FRequestUserList");
766 return 0; 771 return 0;
767 } 772 }
768 else 773 else