Mercurial > pidgin
comparison src/protocols/oscar/ft.c @ 11399:48244c196228
[gaim-migrate @ 13634]
Fix some warnings? Get rid of some whitespace. My usual mucking about
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 01 Sep 2005 02:09:56 +0000 |
parents | ab0fa7cd61cc |
children | 69b0378c79e0 |
comparison
equal
deleted
inserted
replaced
11398:90290f579926 | 11399:48244c196228 |
---|---|
821 fh->recvcsum = aimbs_get32(bs); | 821 fh->recvcsum = aimbs_get32(bs); |
822 aimbs_getrawbuf(bs, (guchar *)fh->idstring, 32); | 822 aimbs_getrawbuf(bs, (guchar *)fh->idstring, 32); |
823 fh->flags = aimbs_get8(bs); | 823 fh->flags = aimbs_get8(bs); |
824 fh->lnameoffset = aimbs_get8(bs); | 824 fh->lnameoffset = aimbs_get8(bs); |
825 fh->lsizeoffset = aimbs_get8(bs); | 825 fh->lsizeoffset = aimbs_get8(bs); |
826 aimbs_getrawbuf(bs, fh->dummy, 69); | 826 aimbs_getrawbuf(bs, (guchar *)fh->dummy, 69); |
827 aimbs_getrawbuf(bs, fh->macfileinfo, 16); | 827 aimbs_getrawbuf(bs, (guchar *)fh->macfileinfo, 16); |
828 fh->nencode = aimbs_get16(bs); | 828 fh->nencode = aimbs_get16(bs); |
829 fh->nlanguage = aimbs_get16(bs); | 829 fh->nlanguage = aimbs_get16(bs); |
830 aimbs_getrawbuf(bs, (guchar *)fh->name, 64); /* XXX - filenames longer than 64B */ | 830 aimbs_getrawbuf(bs, (guchar *)fh->name, 64); /* XXX - filenames longer than 64B */ |
831 fh->name[63] = '\0'; | 831 fh->name[63] = '\0'; |
832 | 832 |
866 aimbs_put32(bs, fh->rfsize); | 866 aimbs_put32(bs, fh->rfsize); |
867 aimbs_put32(bs, fh->cretime); | 867 aimbs_put32(bs, fh->cretime); |
868 aimbs_put32(bs, fh->rfcsum); | 868 aimbs_put32(bs, fh->rfcsum); |
869 aimbs_put32(bs, fh->nrecvd); | 869 aimbs_put32(bs, fh->nrecvd); |
870 aimbs_put32(bs, fh->recvcsum); | 870 aimbs_put32(bs, fh->recvcsum); |
871 aimbs_putraw(bs, (const guchar *)fh->idstring, 32); | 871 aimbs_putraw(bs, (guchar *)fh->idstring, 32); |
872 aimbs_put8(bs, fh->flags); | 872 aimbs_put8(bs, fh->flags); |
873 aimbs_put8(bs, fh->lnameoffset); | 873 aimbs_put8(bs, fh->lnameoffset); |
874 aimbs_put8(bs, fh->lsizeoffset); | 874 aimbs_put8(bs, fh->lsizeoffset); |
875 aimbs_putraw(bs, fh->dummy, 69); | 875 aimbs_putraw(bs, (guchar *)fh->dummy, 69); |
876 aimbs_putraw(bs, fh->macfileinfo, 16); | 876 aimbs_putraw(bs, (guchar *)fh->macfileinfo, 16); |
877 aimbs_put16(bs, fh->nencode); | 877 aimbs_put16(bs, fh->nencode); |
878 aimbs_put16(bs, fh->nlanguage); | 878 aimbs_put16(bs, fh->nlanguage); |
879 aimbs_putraw(bs, (const guchar *)fh->name, 64); /* XXX - filenames longer than 64B */ | 879 aimbs_putraw(bs, (guchar *)fh->name, 64); /* XXX - filenames longer than 64B */ |
880 | 880 |
881 return 0; | 881 return 0; |
882 } | 882 } |
883 | 883 |
884 /** | 884 /** |
944 aim_bstream_t bs; | 944 aim_bstream_t bs; |
945 fu8_t *bs_raw; | 945 fu8_t *bs_raw; |
946 fu16_t packet_len; | 946 fu16_t packet_len; |
947 fu8_t sn_len; | 947 fu8_t sn_len; |
948 int err; | 948 int err; |
949 | 949 |
950 err = 0; | 950 err = 0; |
951 | 951 |
952 if (!proxy_info) | 952 if (!proxy_info) |
953 return -EINVAL; | 953 return -EINVAL; |
954 | 954 |
955 sn_len = strlen(proxy_info->sess->sn); | 955 sn_len = strlen(proxy_info->sess->sn); |
956 packet_len = 2 + 2 /* packet_len, packet_ver */ | 956 packet_len = 2 + 2 /* packet_len, packet_ver */ |
958 + 2 /* flags */ | 958 + 2 /* flags */ |
959 + 1 + sn_len /* Length/value pair for screenname */ | 959 + 1 + sn_len /* Length/value pair for screenname */ |
960 + 8 /* ICBM Cookie */ | 960 + 8 /* ICBM Cookie */ |
961 + 2 /* port */ | 961 + 2 /* port */ |
962 + 2 + 2 + 16; /* TLV for Filesend capability block */ | 962 + 2 + 2 + 16; /* TLV for Filesend capability block */ |
963 | 963 |
964 if (!(bs_raw = malloc(packet_len))) | 964 if (!(bs_raw = malloc(packet_len))) |
965 return -ENOMEM; | 965 return -ENOMEM; |
966 | 966 |
967 aim_bstream_init(&bs, bs_raw, packet_len); | 967 aim_bstream_init(&bs, bs_raw, packet_len); |
968 aimbs_put16(&bs, packet_len - 2); /* Length includes only packets after length marker */ | 968 aimbs_put16(&bs, packet_len - 2); /* Length includes only packets after length marker */ |
969 aimbs_put16(&bs, proxy_info->packet_ver); | 969 aimbs_put16(&bs, proxy_info->packet_ver); |
970 aimbs_put16(&bs, AIM_RV_PROXY_INIT_RECV); | 970 aimbs_put16(&bs, AIM_RV_PROXY_INIT_RECV); |
971 aimbs_put32(&bs, proxy_info->unknownA); | 971 aimbs_put32(&bs, proxy_info->unknownA); |
972 aimbs_put16(&bs, proxy_info->flags); | 972 aimbs_put16(&bs, proxy_info->flags); |
973 aimbs_put8(&bs, sn_len); | 973 aimbs_put8(&bs, sn_len); |
974 aimbs_putraw(&bs, proxy_info->sess->sn, sn_len); | 974 aimbs_putraw(&bs, (const guchar *)proxy_info->sess->sn, sn_len); |
975 aimbs_put16(&bs, proxy_info->port); | 975 aimbs_put16(&bs, proxy_info->port); |
976 aimbs_putraw(&bs, proxy_info->cookie, 8); | 976 aimbs_putraw(&bs, proxy_info->cookie, 8); |
977 | 977 |
978 aimbs_put16(&bs, 0x0001); /* Type */ | 978 aimbs_put16(&bs, 0x0001); /* Type */ |
979 aimbs_put16(&bs, 16); /* Length */ | 979 aimbs_put16(&bs, 16); /* Length */ |
980 aimbs_putcaps(&bs, AIM_CAPS_SENDFILE); /* Value */ | 980 aimbs_putcaps(&bs, AIM_CAPS_SENDFILE); /* Value */ |
981 | 981 |
982 // TODO: Use built-in TLV | 982 // TODO: Use built-in TLV |
983 //aim_tlvlist_add_caps(&tlvlist_sendfile, 0x0001, AIM_CAPS_SENDFILE); | 983 //aim_tlvlist_add_caps(&tlvlist_sendfile, 0x0001, AIM_CAPS_SENDFILE); |
984 //aim_tlvlist_write(&bs, &tlvlist_sendfile); | 984 //aim_tlvlist_write(&bs, &tlvlist_sendfile); |
985 | 985 |
986 aim_bstream_rewind(&bs); | 986 aim_bstream_rewind(&bs); |
987 if (aim_bstream_send(&bs, proxy_info->conn, packet_len) != packet_len) | 987 if (aim_bstream_send(&bs, proxy_info->conn, packet_len) != packet_len) |
988 err = errno; | 988 err = errno; |
989 proxy_info->conn->lastactivity = time(NULL); | 989 proxy_info->conn->lastactivity = time(NULL); |
990 | 990 |
991 //aim_tlvlist_free(tlvlist_sendfile); | 991 //aim_tlvlist_free(tlvlist_sendfile); |
992 free(bs_raw); | 992 free(bs_raw); |
993 | 993 |
994 return err; | 994 return err; |
995 } | 995 } |
1010 aim_bstream_t bs; | 1010 aim_bstream_t bs; |
1011 fu8_t *bs_raw; | 1011 fu8_t *bs_raw; |
1012 fu16_t packet_len; | 1012 fu16_t packet_len; |
1013 fu8_t sn_len; | 1013 fu8_t sn_len; |
1014 int err; | 1014 int err; |
1015 | 1015 |
1016 err = 0; | 1016 err = 0; |
1017 | 1017 |
1018 if (!proxy_info) | 1018 if (!proxy_info) |
1019 return -EINVAL; | 1019 return -EINVAL; |
1020 | 1020 |
1021 sn_len = strlen(proxy_info->sess->sn); | 1021 sn_len = strlen(proxy_info->sess->sn); |
1022 packet_len = 2 + 2 /* packet_len, packet_ver */ | 1022 packet_len = 2 + 2 /* packet_len, packet_ver */ |
1023 + 2 + 4 /* cmd_type, unknownA */ | 1023 + 2 + 4 /* cmd_type, unknownA */ |
1024 + 2 /* flags */ | 1024 + 2 /* flags */ |
1025 + 1 + sn_len /* Length/value pair for screenname */ | 1025 + 1 + sn_len /* Length/value pair for screenname */ |
1026 + 8 /* ICBM Cookie */ | 1026 + 8 /* ICBM Cookie */ |
1027 + 2 + 2 + 16; /* TLV for Filesend capability block */ | 1027 + 2 + 2 + 16; /* TLV for Filesend capability block */ |
1028 | 1028 |
1029 if (!(bs_raw = malloc(packet_len))) | 1029 if (!(bs_raw = malloc(packet_len))) |
1030 return -ENOMEM; | 1030 return -ENOMEM; |
1031 | 1031 |
1032 aim_bstream_init(&bs, bs_raw, packet_len); | 1032 aim_bstream_init(&bs, bs_raw, packet_len); |
1033 aimbs_put16(&bs, packet_len - 2); /* Length includes only packets after length marker */ | 1033 aimbs_put16(&bs, packet_len - 2); /* Length includes only packets after length marker */ |
1034 aimbs_put16(&bs, proxy_info->packet_ver); | 1034 aimbs_put16(&bs, proxy_info->packet_ver); |
1035 aimbs_put16(&bs, AIM_RV_PROXY_INIT_SEND); | 1035 aimbs_put16(&bs, AIM_RV_PROXY_INIT_SEND); |
1036 aimbs_put32(&bs, proxy_info->unknownA); | 1036 aimbs_put32(&bs, proxy_info->unknownA); |
1037 aimbs_put16(&bs, proxy_info->flags); | 1037 aimbs_put16(&bs, proxy_info->flags); |
1038 aimbs_put8(&bs, sn_len); | 1038 aimbs_put8(&bs, sn_len); |
1039 aimbs_putraw(&bs, proxy_info->sess->sn, sn_len); | 1039 aimbs_putraw(&bs, (const guchar *)proxy_info->sess->sn, sn_len); |
1040 aimbs_putraw(&bs, proxy_info->cookie, 8); | 1040 aimbs_putraw(&bs, proxy_info->cookie, 8); |
1041 | 1041 |
1042 aimbs_put16(&bs, 0x0001); /* Type */ | 1042 aimbs_put16(&bs, 0x0001); /* Type */ |
1043 aimbs_put16(&bs, 16); /* Length */ | 1043 aimbs_put16(&bs, 16); /* Length */ |
1044 aimbs_putcaps(&bs, AIM_CAPS_SENDFILE); /* Value */ | 1044 aimbs_putcaps(&bs, AIM_CAPS_SENDFILE); /* Value */ |
1045 | 1045 |
1046 // TODO: Use built-in TLV | 1046 // TODO: Use built-in TLV |
1047 //aim_tlvlist_add_caps(&tlvlist_sendfile, 0x0001, AIM_CAPS_SENDFILE); | 1047 //aim_tlvlist_add_caps(&tlvlist_sendfile, 0x0001, AIM_CAPS_SENDFILE); |
1048 //aim_tlvlist_write(&bs, &tlvlist_sendfile); | 1048 //aim_tlvlist_write(&bs, &tlvlist_sendfile); |
1049 | 1049 |
1050 aim_bstream_rewind(&bs); | 1050 aim_bstream_rewind(&bs); |
1051 if (aim_bstream_send(&bs, proxy_info->conn, packet_len) != packet_len) | 1051 if (aim_bstream_send(&bs, proxy_info->conn, packet_len) != packet_len) |
1052 err = errno; | 1052 err = errno; |
1053 proxy_info->conn->lastactivity = time(NULL); | 1053 proxy_info->conn->lastactivity = time(NULL); |
1054 | 1054 |
1055 //aim_tlvlist_free(tlvlist_sendfile); | 1055 //aim_tlvlist_free(tlvlist_sendfile); |
1056 free(bs_raw); | 1056 free(bs_raw); |
1057 | 1057 |
1058 return err; | 1058 return err; |
1059 } | 1059 } |
1060 | 1060 |
1061 /** | 1061 /** |
1062 * Handle incoming data on a rendezvous connection. This is analogous to the | 1062 * Handle incoming data on a rendezvous connection. This is analogous to the |
1063 * consumesnac function in rxhandlers.c, and I really think this should probably | 1063 * consumesnac function in rxhandlers.c, and I really think this should probably |
1064 * be in rxhandlers.c as well, but I haven't finished cleaning everything up yet. | 1064 * be in rxhandlers.c as well, but I haven't finished cleaning everything up yet. |
1065 * | 1065 * |
1066 * @param sess The session. | 1066 * @param sess The session. |
1067 * @param fr The frame allocated for the incoming data. | 1067 * @param fr The frame allocated for the incoming data. |
1068 * @return Return 0 if the packet was handled correctly, otherwise return the | 1068 * @return Return 0 if the packet was handled correctly, otherwise return the |
1069 * error number. | 1069 * error number. |
1070 */ | 1070 */ |
1071 faim_internal int aim_rxdispatch_rendezvous(aim_session_t *sess, aim_frame_t *fr) | 1071 faim_internal int aim_rxdispatch_rendezvous(aim_session_t *sess, aim_frame_t *fr) |
1072 { | 1072 { |
1073 aim_conn_t *conn = fr->conn; | 1073 aim_conn_t *conn = fr->conn; |
1156 if(len == AIM_RV_PROXY_ACK_LEN - 2) { | 1156 if(len == AIM_RV_PROXY_ACK_LEN - 2) { |
1157 body_len = AIM_RV_PROXY_ACK_LEN - AIM_RV_PROXY_HDR_LEN; | 1157 body_len = AIM_RV_PROXY_ACK_LEN - AIM_RV_PROXY_HDR_LEN; |
1158 body_buf = malloc(body_len); | 1158 body_buf = malloc(body_len); |
1159 aim_bstream_init(&bs_body, body_buf, body_len); | 1159 aim_bstream_init(&bs_body, body_buf, body_len); |
1160 if (aim_bstream_recv(&bs_body, conn->fd, body_len) == body_len) { | 1160 if (aim_bstream_recv(&bs_body, conn->fd, body_len) == body_len) { |
1161 int i; | |
1161 aim_bstream_rewind(&bs_body); | 1162 aim_bstream_rewind(&bs_body); |
1162 proxy_info->port = aimbs_get16(&bs_body); | 1163 proxy_info->port = aimbs_get16(&bs_body); |
1163 int i; | |
1164 for(i=0; i<4; i++) | 1164 for(i=0; i<4; i++) |
1165 ip_temp[i] = aimbs_get8(&bs_body); | 1165 ip_temp[i] = aimbs_get8(&bs_body); |
1166 snprintf(str_ip, sizeof(str_ip), "%hhu.%hhu.%hhu.%hhu", | 1166 snprintf(str_ip, sizeof(str_ip), "%hhu.%hhu.%hhu.%hhu", |
1167 ip_temp[0], ip_temp[1], | 1167 ip_temp[0], ip_temp[1], |
1168 ip_temp[2], ip_temp[3]); | 1168 ip_temp[2], ip_temp[3]); |