Mercurial > pidgin
comparison src/protocols/irc/irc.c @ 5298:857106f8f971
[gaim-migrate @ 5670]
don't let CTCP pings segfault gaim ;-)
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Mon, 05 May 2003 20:57:12 +0000 |
parents | 0e2cc6379618 |
children | ee2b7e4de04e |
comparison
equal
deleted
inserted
replaced
5297:d4c9c5491812 | 5298:857106f8f971 |
---|---|
1681 gchar **vector; | 1681 gchar **vector; |
1682 | 1682 |
1683 if (p) | 1683 if (p) |
1684 *p = 0; | 1684 *p = 0; |
1685 | 1685 |
1686 vector = g_strsplit(word_eol[5], " ", 2); | 1686 vector = g_strsplit(word_eol[5], ".", 2); |
1687 | 1687 |
1688 if (gettimeofday(&now, NULL) == 0 && vector != NULL) { | 1688 if (gettimeofday(&now, NULL) == 0 && vector != NULL) { |
1689 if (now.tv_usec - atol(vector[1]) < 0) { | 1689 if (vector[1] && now.tv_usec - atol(vector[1]) < 0) { |
1690 ping_time.tv_sec = now.tv_sec - atol(vector[0]) - 1; | 1690 ping_time.tv_sec = now.tv_sec - atol(vector[0]) - 1; |
1691 ping_time.tv_usec = now.tv_usec - atol(vector[1]) + 1000000; | 1691 ping_time.tv_usec = now.tv_usec - atol(vector[1]) + 1000000; |
1692 | 1692 |
1693 } else { | 1693 } else { |
1694 ping_time.tv_sec = now.tv_sec - atol(vector[0]); | 1694 ping_time.tv_sec = now.tv_sec - atol(vector[0]); |
1695 ping_time.tv_usec = now.tv_usec - atol(vector[1]); | 1695 if(vector[1]) |
1696 ping_time.tv_usec = now.tv_usec - atol(vector[1]); | |
1696 } | 1697 } |
1697 | 1698 |
1698 g_snprintf(buf, sizeof(buf), | 1699 g_snprintf(buf, sizeof(buf), |
1699 "CTCP Ping reply from %s: %lu.%.03lu seconds", | 1700 "CTCP Ping reply from %s: %lu.%.03lu seconds", |
1700 nick, ping_time.tv_sec, (ping_time.tv_usec/1000)); | 1701 nick, ping_time.tv_sec, (ping_time.tv_usec/1000)); |
2792 | 2793 |
2793 static void | 2794 static void |
2794 irc_ctcp_ping(struct gaim_connection *gc, const char *who) | 2795 irc_ctcp_ping(struct gaim_connection *gc, const char *who) |
2795 { | 2796 { |
2796 char buf[IRC_BUF_LEN]; | 2797 char buf[IRC_BUF_LEN]; |
2797 | 2798 struct timeval now; |
2798 g_snprintf (buf, sizeof(buf), "\001PING %ld\001", time(NULL)); | 2799 |
2800 gettimeofday(&now, NULL); | |
2801 g_snprintf (buf, sizeof(buf), "\001PING %lu.%.03lu\001", now.tv_sec, | |
2802 now.tv_usec/1000); | |
2799 irc_send_privmsg(gc, who, buf, FALSE); | 2803 irc_send_privmsg(gc, who, buf, FALSE); |
2800 } | 2804 } |
2801 | 2805 |
2802 static void | 2806 static void |
2803 irc_send_notice(struct gaim_connection *gc, char *who, char *what) | 2807 irc_send_notice(struct gaim_connection *gc, char *who, char *what) |