Mercurial > pidgin
comparison plugins/irc.c @ 1831:1b61db419774
[gaim-migrate @ 1841]
hi rob! (just a few cleanups, irc passes -Wall :) )
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 09 May 2001 21:14:13 +0000 |
parents | 1e0613d9526b |
children | 1d137dde946f |
comparison
equal
deleted
inserted
replaced
1830:086213e7fb73 | 1831:1b61db419774 |
---|---|
120 GSList *grp = gc->groups; | 120 GSList *grp = gc->groups; |
121 GSList *person; | 121 GSList *person; |
122 struct group *g; | 122 struct group *g; |
123 struct buddy *b; | 123 struct buddy *b; |
124 struct irc_channel *u; | 124 struct irc_channel *u; |
125 gchar buf[IRC_BUF_LEN + 1]; | |
126 | 125 |
127 if (idata->templist != NULL) | 126 if (idata->templist != NULL) |
128 return; | 127 return; |
129 | 128 |
130 idata->recblocks = 0; | 129 idata->recblocks = 0; |
467 | 466 |
468 | 467 |
469 } | 468 } |
470 static struct conversation *find_conversation_by_id(struct gaim_connection *gc, int id) | 469 static struct conversation *find_conversation_by_id(struct gaim_connection *gc, int id) |
471 { | 470 { |
472 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
473 GSList *bc = gc->buddy_chats; | 471 GSList *bc = gc->buddy_chats; |
474 struct conversation *b = NULL; | 472 struct conversation *b = NULL; |
475 | 473 |
476 while (bc) { | 474 while (bc) { |
477 b = (struct conversation *)bc->data; | 475 b = (struct conversation *)bc->data; |
489 return b; | 487 return b; |
490 } | 488 } |
491 | 489 |
492 static struct conversation *find_conversation_by_name(struct gaim_connection *gc, char *name) | 490 static struct conversation *find_conversation_by_name(struct gaim_connection *gc, char *name) |
493 { | 491 { |
494 struct irc_data *idata = (struct irc_data *)gc->proto_data; | |
495 GSList *bc = gc->buddy_chats; | 492 GSList *bc = gc->buddy_chats; |
496 struct conversation *b = NULL; | 493 struct conversation *b = NULL; |
497 | 494 |
498 while (bc) { | 495 while (bc) { |
499 int x; | |
500 b = (struct conversation *)bc->data; | 496 b = (struct conversation *)bc->data; |
501 | 497 |
502 if (g_strcasecmp(name, b->name) == 0) { | 498 if (g_strcasecmp(name, b->name) == 0) { |
503 break; | 499 break; |
504 } | 500 } |
743 return; | 739 return; |
744 | 740 |
745 } | 741 } |
746 | 742 |
747 | 743 |
748 if ((strstr(buf, " JOIN ")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { | 744 if ((strstr(buf, " JOIN ")) && (strstr(buf, "!")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { |
749 | 745 |
750 gchar u_channel[128]; | 746 gchar u_channel[128]; |
751 gchar u_nick[128]; | 747 gchar u_nick[128]; |
752 | 748 |
753 struct irc_channel *channel; | 749 struct irc_channel *channel; |
754 int id; | |
755 int j; | 750 int j; |
756 | 751 |
757 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | 752 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { |
758 u_nick[j] = buf[i]; | 753 u_nick[j] = buf[i]; |
759 } | 754 } |
802 } | 797 } |
803 | 798 |
804 return; | 799 return; |
805 } | 800 } |
806 | 801 |
807 if ((strstr(buf, " NICK ")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { | 802 if ((strstr(buf, " NICK ")) && (strstr(buf, "!")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { |
808 | 803 |
809 gchar old[128]; | 804 gchar old[128]; |
810 gchar new[128]; | 805 gchar new[128]; |
811 | 806 |
812 GList *templist; | 807 GList *templist; |
813 | 808 |
814 struct irc_channel *channel; | 809 struct irc_channel *channel; |
815 int id; | |
816 int j; | 810 int j; |
817 | 811 |
818 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | 812 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { |
819 old[j] = buf[i]; | 813 old[j] = buf[i]; |
820 } | 814 } |
842 | 836 |
843 templist = templist->next; | 837 templist = templist->next; |
844 } | 838 } |
845 } | 839 } |
846 | 840 |
847 if ((strstr(buf, "QUIT ")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { | 841 if ((strstr(buf, "QUIT ")) && (buf[0] == ':') && (strstr(buf, "!")) && (!strstr(buf, " NOTICE "))) { |
848 | 842 |
849 gchar u_nick[128]; | 843 gchar u_nick[128]; |
850 | 844 |
851 GList *templist; | 845 GList *templist; |
852 | 846 |
871 | 865 |
872 templist = templist->next; | 866 templist = templist->next; |
873 } | 867 } |
874 } | 868 } |
875 | 869 |
876 if ((strstr(buf, " PART ")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { | 870 if ((strstr(buf, " PART ")) && (strstr(buf, "!")) && (buf[0] == ':') && (!strstr(buf, " NOTICE "))) { |
877 | 871 |
878 gchar u_channel[128]; | 872 gchar u_channel[128]; |
879 gchar u_nick[128]; | 873 gchar u_nick[128]; |
880 | 874 |
881 struct irc_channel *channel; | 875 struct irc_channel *channel; |
882 int id; | |
883 int j; | 876 int j; |
884 GList *test = NULL; | |
885 | 877 |
886 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | 878 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { |
887 u_nick[j] = buf[i]; | 879 u_nick[j] = buf[i]; |
888 } | 880 } |
889 u_nick[j] = '\0'; | 881 u_nick[j] = '\0'; |
944 gchar u_host[255]; | 936 gchar u_host[255]; |
945 gchar u_command[32]; | 937 gchar u_command[32]; |
946 gchar u_channel[128]; | 938 gchar u_channel[128]; |
947 gchar u_message[IRC_BUF_LEN]; | 939 gchar u_message[IRC_BUF_LEN]; |
948 int j; | 940 int j; |
949 int msgcode = 0; | |
950 | 941 |
951 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | 942 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { |
952 u_nick[j] = buf[i]; | 943 u_nick[j] = buf[i]; |
953 } | 944 } |
954 | 945 |
1012 gchar u_host[255]; | 1003 gchar u_host[255]; |
1013 gchar u_command[32]; | 1004 gchar u_command[32]; |
1014 gchar u_channel[128]; | 1005 gchar u_channel[128]; |
1015 gchar u_message[IRC_BUF_LEN]; | 1006 gchar u_message[IRC_BUF_LEN]; |
1016 int j; | 1007 int j; |
1017 int msgcode = 0; | |
1018 | 1008 |
1019 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { | 1009 for (j = 0, i = 1; buf[i] != '!'; j++, i++) { |
1020 u_nick[j] = buf[i]; | 1010 u_nick[j] = buf[i]; |
1021 } | 1011 } |
1022 | 1012 |
1226 struct sockaddr_in site; | 1216 struct sockaddr_in site; |
1227 char buf[4096]; | 1217 char buf[4096]; |
1228 | 1218 |
1229 struct gaim_connection *gc = new_gaim_conn(user); | 1219 struct gaim_connection *gc = new_gaim_conn(user); |
1230 struct irc_data *idata = gc->proto_data = g_new0(struct irc_data, 1); | 1220 struct irc_data *idata = gc->proto_data = g_new0(struct irc_data, 1); |
1231 char c; | |
1232 int i; | |
1233 int status; | |
1234 | 1221 |
1235 host = gethostbyname(user->proto_opt[0]); | 1222 host = gethostbyname(user->proto_opt[0]); |
1236 if (!host) { | 1223 if (!host) { |
1237 hide_login_progress(gc, "Unable to resolve hostname"); | 1224 hide_login_progress(gc, "Unable to resolve hostname"); |
1238 signoff(gc); | 1225 signoff(gc); |
1362 static void irc_get_info(struct gaim_connection *gc, char *who) | 1349 static void irc_get_info(struct gaim_connection *gc, char *who) |
1363 { | 1350 { |
1364 struct irc_data *idata = (struct irc_data *)gc->proto_data; | 1351 struct irc_data *idata = (struct irc_data *)gc->proto_data; |
1365 char buf[BUF_LEN]; | 1352 char buf[BUF_LEN]; |
1366 | 1353 |
1367 if ((who[0] == '@') || (who[0] == '+') && (strlen(who)>1)) | 1354 if (((who[0] == '@') || (who[0] == '+')) && (strlen(who)>1)) |
1368 g_snprintf(buf, BUF_LEN, "WHOIS %s\n", who+1); | 1355 g_snprintf(buf, BUF_LEN, "WHOIS %s\n", who+1); |
1369 else | 1356 else |
1370 g_snprintf(buf, BUF_LEN, "WHOIS %s\n", who); | 1357 g_snprintf(buf, BUF_LEN, "WHOIS %s\n", who); |
1371 write(idata->fd, buf, strlen(buf)); | 1358 write(idata->fd, buf, strlen(buf)); |
1372 } | 1359 } |