Mercurial > pidgin
comparison src/protocols/oscar/ft.c @ 3717:988485669631
[gaim-migrate @ 3850]
Warning fixes and WIN32 ifdef removals
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Wed, 16 Oct 2002 19:57:03 +0000 |
parents | e597186997d5 |
children | b32474e522fa |
comparison
equal
deleted
inserted
replaced
3716:d7e83b4db191 | 3717:988485669631 |
---|---|
60 | 60 |
61 if ((acceptfd = accept(cur->fd, &cliaddr, &clilen)) == -1) | 61 if ((acceptfd = accept(cur->fd, &cliaddr, &clilen)) == -1) |
62 return 0; /* not an error */ | 62 return 0; /* not an error */ |
63 | 63 |
64 if (cliaddr.sa_family != AF_INET) { /* just in case IPv6 really is happening */ | 64 if (cliaddr.sa_family != AF_INET) { /* just in case IPv6 really is happening */ |
65 #ifndef _WIN32 | |
66 close(acceptfd); | 65 close(acceptfd); |
67 #else | |
68 closesocket(acceptfd); | |
69 #endif | |
70 aim_conn_close(cur); | 66 aim_conn_close(cur); |
71 return -1; | 67 return -1; |
72 } | 68 } |
73 | 69 |
74 if (!(newconn = aim_cloneconn(sess, cur))) { | 70 if (!(newconn = aim_cloneconn(sess, cur))) { |
75 #ifndef _WIN32 | |
76 close(acceptfd); | 71 close(acceptfd); |
77 #else | |
78 closesocket(acceptfd); | |
79 #endif | |
80 aim_conn_close(cur); | 72 aim_conn_close(cur); |
81 return -1; | 73 return -1; |
82 } | 74 } |
83 | 75 |
84 newconn->type = AIM_CONN_TYPE_RENDEZVOUS; | 76 newconn->type = AIM_CONN_TYPE_RENDEZVOUS; |
340 cookie->data = priv; | 332 cookie->data = priv; |
341 aim_cachecookie(sess, cookie); | 333 aim_cachecookie(sess, cookie); |
342 | 334 |
343 /* XXX switch to aim_cloneconn()? */ | 335 /* XXX switch to aim_cloneconn()? */ |
344 if (!(newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS_OUT, NULL))) { | 336 if (!(newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS_OUT, NULL))) { |
345 #ifndef _WIN32 | |
346 close(listenfd); | 337 close(listenfd); |
347 #else | |
348 closesocket(listenfd); | |
349 #endif | |
350 return NULL; | 338 return NULL; |
351 } | 339 } |
352 | 340 |
353 /* this one is for the conn */ | 341 /* this one is for the conn */ |
354 priv = (struct aim_directim_intdata *)calloc(1, sizeof(struct aim_directim_intdata)); | 342 priv = (struct aim_directim_intdata *)calloc(1, sizeof(struct aim_directim_intdata)); |
415 strncpy(ft->sn, destsn, sizeof(ft->sn)); | 403 strncpy(ft->sn, destsn, sizeof(ft->sn)); |
416 cookie->data = ft; | 404 cookie->data = ft; |
417 aim_cachecookie(sess, cookie); | 405 aim_cachecookie(sess, cookie); |
418 | 406 |
419 if (!(newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS_OUT, NULL))) { | 407 if (!(newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS_OUT, NULL))) { |
420 #ifndef _WIN32 | |
421 close(listenfd); | 408 close(listenfd); |
422 #else | |
423 closesocket(listenfd); | |
424 #endif | |
425 return NULL; | 409 return NULL; |
426 } | 410 } |
427 | 411 |
428 /* this one is for the conn */ | 412 /* this one is for the conn */ |
429 ft = (struct aim_filetransfer_priv *)calloc(1, sizeof(struct aim_filetransfer_priv)); | 413 ft = (struct aim_filetransfer_priv *)calloc(1, sizeof(struct aim_filetransfer_priv)); |
943 continue; | 927 continue; |
944 setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); | 928 setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); |
945 if (bind(listenfd, res->ai_addr, res->ai_addrlen) == 0) | 929 if (bind(listenfd, res->ai_addr, res->ai_addrlen) == 0) |
946 break; | 930 break; |
947 /* success */ | 931 /* success */ |
948 #ifndef _WIN32 | |
949 close(listenfd); | 932 close(listenfd); |
950 #else | |
951 closesocket(listenfd); | |
952 #endif | |
953 } while ( (res = res->ai_next) ); | 933 } while ( (res = res->ai_next) ); |
954 | 934 |
955 if (!res) | 935 if (!res) |
956 return -1; | 936 return -1; |
957 | 937 |
966 return listenfd; | 946 return listenfd; |
967 #else | 947 #else |
968 int listenfd; | 948 int listenfd; |
969 const int on = 1; | 949 const int on = 1; |
970 struct sockaddr_in sockin; | 950 struct sockaddr_in sockin; |
971 #ifdef _WIN32 | |
972 u_long imode; | |
973 #endif | |
974 | 951 |
975 if ((listenfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { | 952 if ((listenfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { |
976 perror("socket(listenfd)"); | 953 perror("socket(listenfd)"); |
977 return -1; | 954 return -1; |
978 } | 955 } |
979 | 956 |
980 if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) != 0) { | 957 if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) != 0) { |
981 perror("setsockopt(listenfd)"); | 958 perror("setsockopt(listenfd)"); |
982 #ifndef _WIN32 | |
983 close(listenfd); | 959 close(listenfd); |
984 #else | |
985 closesocket(listenfd); | |
986 #endif | |
987 return -1; | 960 return -1; |
988 } | 961 } |
989 | 962 |
990 memset(&sockin, 0, sizeof(struct sockaddr_in)); | 963 memset(&sockin, 0, sizeof(struct sockaddr_in)); |
991 sockin.sin_family = AF_INET; | 964 sockin.sin_family = AF_INET; |
992 sockin.sin_port = htons(portnum); | 965 sockin.sin_port = htons(portnum); |
993 | 966 |
994 if (bind(listenfd, (struct sockaddr *)&sockin, sizeof(struct sockaddr_in)) != 0) { | 967 if (bind(listenfd, (struct sockaddr *)&sockin, sizeof(struct sockaddr_in)) != 0) { |
995 perror("bind(listenfd)"); | 968 perror("bind(listenfd)"); |
996 #ifndef _WIN32 | |
997 close(listenfd); | 969 close(listenfd); |
998 #else | |
999 closesocket(listenfd); | |
1000 #endif | |
1001 return -1; | 970 return -1; |
1002 } | 971 } |
1003 if (listen(listenfd, 4) != 0) { | 972 if (listen(listenfd, 4) != 0) { |
1004 perror("listen(listenfd)"); | 973 perror("listen(listenfd)"); |
1005 #ifndef _WIN32 | |
1006 close(listenfd); | 974 close(listenfd); |
1007 #else | 975 return -1; |
1008 closesocket(listenfd); | 976 } |
1009 #endif | |
1010 return -1; | |
1011 } | |
1012 #ifndef _WIN32 | |
1013 fcntl(listenfd, F_SETFL, O_NONBLOCK); | 977 fcntl(listenfd, F_SETFL, O_NONBLOCK); |
1014 #else | |
1015 imode = 1; | |
1016 ioctlsocket(listenfd, FIONBIO, &imode); | |
1017 #endif | |
1018 return listenfd; | 978 return listenfd; |
1019 #endif | 979 #endif |
1020 } | 980 } |
1021 | 981 |
1022 static int getcommand_getfile(aim_session_t *sess, aim_conn_t *conn) | 982 static int getcommand_getfile(aim_session_t *sess, aim_conn_t *conn) |