Mercurial > pidgin
annotate src/win32/libc_interface.c @ 10311:b7566fc34c6c
[gaim-migrate @ 11505]
Hitting the enter key when you're cursor is in the alias field of the
Add Chat dialog now activates the dialogs default action.
Closes bug 1075200 and patch 1078079. Thanks to Andrew Hart for
taking a stab at this and wounding, but not killing. Killing is wrong!
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 03 Dec 2004 04:02:10 +0000 |
parents | 5e78d07f6b36 |
children | 0f7452b1f777 |
rev | line source |
---|---|
3712
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
1 /* |
5913
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
2 * gaim |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
3 * |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
4 * File: libc_interface.c |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
5 * Date: October 14, 2002 |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
6 * Description: libc interface for Windows api |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
7 * |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
8 * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
9 * |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
10 * This program is free software; you can redistribute it and/or modify |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
11 * it under the terms of the GNU General Public License as published by |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
12 * the Free Software Foundation; either version 2 of the License, or |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
13 * (at your option) any later version. |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
14 * |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
15 * This program is distributed in the hope that it will be useful, |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
18 * GNU General Public License for more details. |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
19 * |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
20 * You should have received a copy of the GNU General Public License |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
21 * along with this program; if not, write to the Free Software |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
23 * |
3712
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
24 */ |
8244
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
25 #include <winsock2.h> |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
26 #include <ws2tcpip.h> |
3777
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
27 #include <io.h> |
3712
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
28 #include <stdlib.h> |
3777
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
29 #include <stdio.h> |
3712
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
30 #include <errno.h> |
3777
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
31 #include <sys/timeb.h> |
4905
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
32 #include <sys/stat.h> |
3777
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
33 #include <time.h> |
6425
26b739bc9f1a
[gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5913
diff
changeset
|
34 #include "debug.h" |
3777
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
35 #include "libc_internal.h" |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
36 |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
37 /* |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
38 * PROTOS |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
39 */ |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
40 |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
41 /* |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
42 * LOCALS |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
43 */ |
3712
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
44 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
45 static char errbuf[1024]; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
46 |
3777
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
47 /* |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
48 * CODE |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
49 */ |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
50 |
3712
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
51 /* helpers */ |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
52 static int wgaim_is_socket( int fd ) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
53 int optval; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
54 unsigned int optlen = sizeof(int); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
55 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
56 if( (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void*)&optval, &optlen)) == SOCKET_ERROR ) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
57 int error = WSAGetLastError(); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
58 if( error == WSAENOTSOCK ) |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
59 return FALSE; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
60 else { |
6425
26b739bc9f1a
[gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5913
diff
changeset
|
61 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "wgaim_is_socket: getsockopt returned error: %d\n", error); |
3712
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
62 return FALSE; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
63 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
64 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
65 return TRUE; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
66 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
67 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
68 /* socket.h */ |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
69 int wgaim_socket (int namespace, int style, int protocol) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
70 int ret; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
71 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
72 ret = socket( namespace, style, protocol ); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
73 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
74 if( ret == INVALID_SOCKET ) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
75 errno = WSAGetLastError(); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
76 return -1; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
77 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
78 return ret; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
79 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
80 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
81 int wgaim_connect(int socket, struct sockaddr *addr, u_long length) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
82 int ret; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
83 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
84 ret = connect( socket, addr, length ); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
85 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
86 if( ret == SOCKET_ERROR ) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
87 errno = WSAGetLastError(); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
88 if( errno == WSAEWOULDBLOCK ) |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
89 errno = WSAEINPROGRESS; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
90 return -1; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
91 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
92 return 0; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
93 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
94 |
8244
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
95 int wgaim_getsockopt(int socket, int level, int optname, void *optval, socklen_t *optlenptr) { |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
96 if(getsockopt(socket, level, optname, optval, optlenptr) == SOCKET_ERROR ) { |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
97 errno = WSAGetLastError(); |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
98 return -1; |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
99 } |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
100 return 0; |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
101 } |
3712
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
102 |
9611 | 103 int wgaim_setsockopt(int socket, int level, int optname, const void *optval, socklen_t optlen) { |
8244
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
104 if(setsockopt(socket, level, optname, optval, optlen) == SOCKET_ERROR ) { |
3712
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
105 errno = WSAGetLastError(); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
106 return -1; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
107 } |
8244
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
108 return 0; |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
109 } |
3712
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
110 |
8244
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
111 int wgaim_getsockname(int socket, struct sockaddr *addr, socklen_t *lenptr) { |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
112 if(getsockname(socket, addr, lenptr) == SOCKET_ERROR) { |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
113 errno = WSAGetLastError(); |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
114 return -1; |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
115 } |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
116 return 0; |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
117 } |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
118 |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
119 int wgaim_bind(int socket, struct sockaddr *addr, socklen_t length) { |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
120 if(bind(socket, addr, length) == SOCKET_ERROR) { |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
121 errno = WSAGetLastError(); |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
122 return -1; |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
123 } |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
124 return 0; |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
125 } |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
126 |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
127 int wgaim_listen(int socket, unsigned int n) { |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
128 if(listen(socket, n) == SOCKET_ERROR) { |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
129 errno = WSAGetLastError(); |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
130 return -1; |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
131 } |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
132 return 0; |
3712
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
133 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
134 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
135 /* fcntl.h */ |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
136 /* This is not a full implementation of fcntl. Update as needed.. */ |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
137 int wgaim_fcntl(int socket, int command, int val) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
138 switch( command ) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
139 case F_SETFL: |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
140 { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
141 int ret=0; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
142 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
143 switch( val ) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
144 case O_NONBLOCK: |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
145 { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
146 u_long imode=1; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
147 ret = ioctlsocket(socket, FIONBIO, &imode); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
148 break; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
149 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
150 case 0: |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
151 { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
152 u_long imode=0; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
153 ret = ioctlsocket(socket, FIONBIO, &imode); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
154 break; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
155 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
156 default: |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
157 errno = EINVAL; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
158 return -1; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
159 }/*end switch*/ |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
160 if( ret == SOCKET_ERROR ) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
161 errno = WSAGetLastError(); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
162 return -1; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
163 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
164 return 0; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
165 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
166 default: |
6425
26b739bc9f1a
[gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5913
diff
changeset
|
167 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "wgaim_fcntl: Unsupported command\n"); |
3712
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
168 return -1; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
169 }/*end switch*/ |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
170 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
171 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
172 /* sys/ioctl.h */ |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
173 int wgaim_ioctl(int fd, int command, void* val) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
174 switch( command ) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
175 case FIONBIO: |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
176 { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
177 if (ioctlsocket(fd, FIONBIO, (unsigned long *)val) == SOCKET_ERROR) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
178 errno = WSAGetLastError(); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
179 return -1; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
180 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
181 return 0; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
182 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
183 default: |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
184 errno = EINVAL; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
185 return -1; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
186 }/*end switch*/ |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
187 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
188 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
189 /* arpa/inet.h */ |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
190 int wgaim_inet_aton(const char *name, struct in_addr *addr) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
191 if((addr->s_addr = inet_addr(name)) == INADDR_NONE) |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
192 return 0; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
193 else |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
194 return 1; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
195 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
196 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
197 /* netdb.h */ |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
198 struct hostent* wgaim_gethostbyname(const char *name) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
199 struct hostent *hp; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
200 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
201 if((hp = gethostbyname(name)) == NULL) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
202 errno = WSAGetLastError(); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
203 return NULL; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
204 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
205 return hp; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
206 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
207 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
208 /* string.h */ |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
209 char* wgaim_strerror( int errornum ) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
210 if( errornum > WSABASEERR ) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
211 sprintf( errbuf, "Windows socket error #%d", errornum ); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
212 return errbuf; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
213 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
214 else |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
215 return strerror( errornum ); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
216 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
217 |
4193
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
218 /* From glibc 2.2.5 */ |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
219 char* wgaim_strsep(char **stringp, const char *delim) { |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
220 char *begin, *end; |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
221 |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
222 begin = *stringp; |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
223 if (begin == NULL) |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
224 return NULL; |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
225 |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
226 /* A frequent case is when the delimiter string contains only one |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
227 character. Here we don't need to call the expensive `strpbrk' |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
228 function and instead work using `strchr'. */ |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
229 if (delim[0] == '\0' || delim[1] == '\0') { |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
230 char ch = delim[0]; |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
231 |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
232 if (ch == '\0') |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
233 end = NULL; |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
234 else { |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
235 if (*begin == ch) |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
236 end = begin; |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
237 else if (*begin == '\0') |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
238 end = NULL; |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
239 else |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
240 end = strchr (begin + 1, ch); |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
241 } |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
242 } |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
243 else |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
244 /* Find the end of the token. */ |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
245 end = strpbrk (begin, delim); |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
246 |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
247 if (end) { |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
248 /* Terminate the token and set *STRINGP past NUL character. */ |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
249 *end++ = '\0'; |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
250 *stringp = end; |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
251 } |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
252 else |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
253 /* No more delimiters; this is the last token. */ |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
254 *stringp = NULL; |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
255 |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
256 return begin; |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
257 } |
c297b9d4f67c
[gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3777
diff
changeset
|
258 |
3712
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
259 /* unistd.h */ |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
260 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
261 /* |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
262 * We need to figure out whether fd is a file or socket handle. |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
263 */ |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
264 int wgaim_read(int fd, void *buf, unsigned int size) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
265 int ret; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
266 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
267 if( wgaim_is_socket(fd) ) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
268 if( (ret = recv(fd, buf, size, 0)) == SOCKET_ERROR ) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
269 errno = WSAGetLastError(); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
270 return -1; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
271 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
272 else if( ret == 0 ) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
273 /* connection has been gracefully closed */ |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
274 errno = WSAENOTCONN; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
275 return -1; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
276 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
277 else { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
278 /* success reading socket */ |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
279 return ret; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
280 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
281 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
282 else { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
283 /* fd is not a socket handle.. pass it off to read */ |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
284 return read(fd, buf, size); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
285 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
286 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
287 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
288 int wgaim_write(int fd, const void *buf, unsigned int size) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
289 int ret; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
290 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
291 if( wgaim_is_socket(fd) ) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
292 if( (ret = send(fd, buf, size, 0)) == SOCKET_ERROR ) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
293 errno = WSAGetLastError(); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
294 return -1; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
295 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
296 else { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
297 /* success */ |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
298 return ret; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
299 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
300 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
301 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
302 else |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
303 return write(fd, buf, size); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
304 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
305 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
306 int wgaim_close(int fd) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
307 int ret; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
308 |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
309 if( wgaim_is_socket(fd) ) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
310 if( (ret = closesocket(fd)) == SOCKET_ERROR ) { |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
311 errno = WSAGetLastError(); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
312 return -1; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
313 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
314 else |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
315 return 0; |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
316 } |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
317 else |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
318 return close(fd); |
ac6ca3890c53
[gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
319 } |
3777
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
320 |
8244
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
321 int wgaim_gethostname(char *name, size_t size) { |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
322 if(gethostname(name, size) == SOCKET_ERROR) { |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
323 errno = WSAGetLastError(); |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
324 return -1; |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
325 } |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
326 return 0; |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
327 } |
5e7ffea3f76a
[gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
328 |
3777
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
329 /* sys/time.h */ |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
330 |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
331 int wgaim_gettimeofday(struct timeval *p, struct timezone *z) { |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
332 int res = 0; |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
333 struct _timeb timebuffer; |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
334 |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
335 if (z != 0) { |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
336 _tzset(); |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
337 z->tz_minuteswest = _timezone/60; |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
338 z->tz_dsttime = _daylight; |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
339 } |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
340 |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
341 if (p != 0) { |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
342 _ftime(&timebuffer); |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
343 p->tv_sec = timebuffer.time; /* seconds since 1-1-1970 */ |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
344 p->tv_usec = timebuffer.millitm*1000; /* microseconds */ |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
345 } |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
346 |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
347 return res; |
10ffafd1c91f
[gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3712
diff
changeset
|
348 } |
4905
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
349 |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
350 /* stdio.h */ |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
351 |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
352 int wgaim_rename (const char *oldname, const char *newname) { |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
353 struct _stat oldstat, newstat; |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
354 |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
355 if(_stat(oldname, &oldstat) == 0) { |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
356 /* newname exists */ |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
357 if(_stat(newname, &newstat) == 0) { |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
358 /* oldname is a dir */ |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
359 if(_S_ISDIR(oldstat.st_mode)) { |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
360 if(!_S_ISDIR(newstat.st_mode)) { |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
361 return rename(oldname, newname); |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
362 } |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
363 /* newname is a dir */ |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
364 else { |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
365 /* This is not quite right.. If newname is empty and |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
366 is not a sub dir of oldname, newname should be |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
367 deleted and oldname should be renamed. |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
368 */ |
6425
26b739bc9f1a
[gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5913
diff
changeset
|
369 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "wgaim_rename does not behave here as it should\n"); |
4905
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
370 return rename(oldname, newname); |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
371 } |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
372 } |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
373 /* oldname is not a dir */ |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
374 else { |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
375 /* newname is a dir */ |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
376 if(_S_ISDIR(newstat.st_mode)) { |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
377 errno = EISDIR; |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
378 return -1; |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
379 } |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
380 /* newname is not a dir */ |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
381 else { |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
382 remove(newname); |
5084
a96653493416
[gaim-migrate @ 5439]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4905
diff
changeset
|
383 return rename(oldname, newname); |
4905
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
384 } |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
385 } |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
386 } |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
387 /* newname doesn't exist */ |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
388 else |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
389 return rename(oldname, newname); |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
390 } |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
391 else { |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
392 /* oldname doesn't exist */ |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
393 errno = ENOENT; |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
394 return -1; |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
395 } |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
396 |
86037d6bf80f
[gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4193
diff
changeset
|
397 } |
5113
bac62d8d386f
[gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5084
diff
changeset
|
398 |
bac62d8d386f
[gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5084
diff
changeset
|
399 /* time.h */ |
bac62d8d386f
[gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5084
diff
changeset
|
400 |
bac62d8d386f
[gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5084
diff
changeset
|
401 struct tm * wgaim_localtime_r (const time_t *time, struct tm *resultp) { |
bac62d8d386f
[gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5084
diff
changeset
|
402 struct tm* tmptm; |
bac62d8d386f
[gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5084
diff
changeset
|
403 |
5474
0b355ec51083
[gaim-migrate @ 5868]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5113
diff
changeset
|
404 if(!time) |
5913
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5474
diff
changeset
|
405 return NULL; |
5113
bac62d8d386f
[gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5084
diff
changeset
|
406 tmptm = localtime(time); |
bac62d8d386f
[gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5084
diff
changeset
|
407 if(resultp && tmptm) |
bac62d8d386f
[gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5084
diff
changeset
|
408 return memcpy(resultp, tmptm, sizeof(struct tm)); |
bac62d8d386f
[gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5084
diff
changeset
|
409 else |
bac62d8d386f
[gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5084
diff
changeset
|
410 return NULL; |
bac62d8d386f
[gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5084
diff
changeset
|
411 } |