| 20 * You should have received a copy of the GNU General Public License |
20 * You should have received a copy of the GNU General Public License |
| 21 * along with this program; if not, write to the Free Software |
21 * along with this program; if not, write to the Free Software |
| 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 23 * |
23 * |
| 24 */ |
24 */ |
| 25 #include <winsock.h> |
25 #include <winsock2.h> |
| |
26 #include <ws2tcpip.h> |
| 26 #include <io.h> |
27 #include <io.h> |
| 27 #include <stdlib.h> |
28 #include <stdlib.h> |
| 28 #include <stdio.h> |
29 #include <stdio.h> |
| 29 #include <errno.h> |
30 #include <errno.h> |
| 30 #include <sys/timeb.h> |
31 #include <sys/timeb.h> |
| 89 return -1; |
90 return -1; |
| 90 } |
91 } |
| 91 return 0; |
92 return 0; |
| 92 } |
93 } |
| 93 |
94 |
| 94 int wgaim_getsockopt(int socket, int level, int optname, void *optval, unsigned int *optlenptr) { |
95 int wgaim_getsockopt(int socket, int level, int optname, void *optval, socklen_t *optlenptr) { |
| 95 int ret; |
96 if(getsockopt(socket, level, optname, optval, optlenptr) == SOCKET_ERROR ) { |
| 96 |
|
| 97 ret = getsockopt( socket, level, optname, optval, optlenptr ); |
|
| 98 if( ret == SOCKET_ERROR ) { |
|
| 99 errno = WSAGetLastError(); |
97 errno = WSAGetLastError(); |
| 100 return -1; |
98 return -1; |
| 101 } |
99 } |
| 102 |
|
| 103 return 0; |
100 return 0; |
| |
101 } |
| |
102 |
| |
103 int wgaim_setsockopt(int socket, int level, int optname, void *optval, socklen_t optlen) { |
| |
104 if(setsockopt(socket, level, optname, optval, optlen) == SOCKET_ERROR ) { |
| |
105 errno = WSAGetLastError(); |
| |
106 return -1; |
| |
107 } |
| |
108 return 0; |
| |
109 } |
| |
110 |
| |
111 int wgaim_getsockname(int socket, struct sockaddr *addr, socklen_t *lenptr) { |
| |
112 if(getsockname(socket, addr, lenptr) == SOCKET_ERROR) { |
| |
113 errno = WSAGetLastError(); |
| |
114 return -1; |
| |
115 } |
| |
116 return 0; |
| |
117 } |
| |
118 |
| |
119 int wgaim_bind(int socket, struct sockaddr *addr, socklen_t length) { |
| |
120 if(bind(socket, addr, length) == SOCKET_ERROR) { |
| |
121 errno = WSAGetLastError(); |
| |
122 return -1; |
| |
123 } |
| |
124 return 0; |
| |
125 } |
| |
126 |
| |
127 int wgaim_listen(int socket, unsigned int n) { |
| |
128 if(listen(socket, n) == SOCKET_ERROR) { |
| |
129 errno = WSAGetLastError(); |
| |
130 return -1; |
| |
131 } |
| |
132 return 0; |
| 104 } |
133 } |
| 105 |
134 |
| 106 /* fcntl.h */ |
135 /* fcntl.h */ |
| 107 /* This is not a full implementation of fcntl. Update as needed.. */ |
136 /* This is not a full implementation of fcntl. Update as needed.. */ |
| 108 int wgaim_fcntl(int socket, int command, int val) { |
137 int wgaim_fcntl(int socket, int command, int val) { |