libpurple/protocols/zephyr/zephyr.c

changeset 33892
ef97228bc5f0
parent 33796
4854740e5277
child 34304
faf0414a8b51
child 34578
cfb2f856a5d0
equal deleted inserted replaced
33891:8b4a41b6fe60 33892:ef97228bc5f0
829 PurpleConvChat *gcc; 829 PurpleConvChat *gcc;
830 char *ptr = (char *) notice.z_message + (strlen(notice.z_message) + 1); 830 char *ptr = (char *) notice.z_message + (strlen(notice.z_message) + 1);
831 int len; 831 int len;
832 char *stripped_sender; 832 char *stripped_sender;
833 int signature_length = strlen(notice.z_message); 833 int signature_length = strlen(notice.z_message);
834 int message_has_no_body = 0;
835 PurpleMessageFlags flags = 0; 834 PurpleMessageFlags flags = 0;
836 gchar *tmpescape; 835 gchar *tmpescape;
837 836
838 /* Need to deal with 0 length messages to handle typing notification (OPCODE) ping messages */ 837 /* Need to deal with 0 length messages to handle typing notification (OPCODE) ping messages */
839 /* One field zephyrs would have caused purple to crash */ 838 /* One field zephyrs would have caused purple to crash */
840 if ( (notice.z_message_len == 0) || (signature_length >= notice.z_message_len - 1)) { 839 if ( (notice.z_message_len == 0) || (signature_length >= notice.z_message_len - 1)) {
841 message_has_no_body = 1; 840 /* message has no body */
842 len = 0; 841 len = 0;
843 purple_debug_info("zephyr","message_size %d %d %d\n",len,notice.z_message_len,signature_length); 842 purple_debug_info("zephyr","message_size %d %d %d\n",len,notice.z_message_len,signature_length);
844 buf3 = g_strdup(""); 843 buf3 = g_strdup("");
845 844
846 } else { 845 } else {
1081 tv.tv_usec = 0; 1080 tv.tv_usec = 0;
1082 incoming_msg=NULL; 1081 incoming_msg=NULL;
1083 1082
1084 while (select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, &tv)) { 1083 while (select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, &tv)) {
1085 selected = 1; 1084 selected = 1;
1086 read(zephyr->fromtzc[ZEPHYR_FD_READ], bufcur, 1); 1085 if (read(zephyr->fromtzc[ZEPHYR_FD_READ], bufcur, 1) != 1) {
1086 purple_debug_error("zephyr", "couldn't read\n");
1087 purple_connection_error(purple_account_get_connection(zephyr->account), PURPLE_CONNECTION_ERROR_NETWORK_ERROR, "couldn't read");
1088 free(buf);
1089 return NULL;
1090 }
1087 bufcur++; 1091 bufcur++;
1088 if ((bufcur - buf) > (bufsize - 1)) { 1092 if ((bufcur - buf) > (bufsize - 1)) {
1089 if ((buf = realloc(buf, bufsize * 2)) == NULL) { 1093 if ((buf = realloc(buf, bufsize * 2)) == NULL) {
1090 purple_debug_error("zephyr","Ran out of memory\n"); 1094 purple_debug_error("zephyr","Ran out of memory\n");
1091 exit(-1); 1095 exit(-1);
1685 1689
1686 FD_ZERO(&rfds); 1690 FD_ZERO(&rfds);
1687 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); 1691 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds);
1688 while (select_status > 0 && 1692 while (select_status > 0 &&
1689 select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, &tv) > 0) { 1693 select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, &tv) > 0) {
1690 read(zephyr->fromtzc[ZEPHYR_FD_READ], bufcur, 1); 1694 if (read(zephyr->fromtzc[ZEPHYR_FD_READ], bufcur, 1) != 1) {
1695 purple_debug_error("zephyr", "couldn't read\n");
1696 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, "couldn't read");
1697 free(buf);
1698 return;
1699 }
1691 bufcur++; 1700 bufcur++;
1692 if ((bufcur - buf) > (bufsize - 1)) { 1701 if ((bufcur - buf) > (bufsize - 1)) {
1693 if ((buf = realloc(buf, bufsize * 2)) == NULL) { 1702 if ((buf = realloc(buf, bufsize * 2)) == NULL) {
1694 exit(-1); 1703 exit(-1);
1695 } else { 1704 } else {

mercurial