Sat, 08 Dec 2018 22:01:50 -0600
libpurple: Include 'glib/gi18n-lib.h' instead of 'libintl.h'
This patch replaces includes of 'libintl.h' with 'glib/gi18n-lib.h'.
The latter defines the macros we use, so we can remove our manual
fallbacks. It also removes 'locale.h' from 'internal.h' as it's
included only where needed now. Lastly, it defines GETTEXT_PACKAGE
to be the same as the PACKAGE define. 'glib/gi18n-lib.h' uses this
for its i18n macros.
| 3712 | 1 | /* |
| 15884 | 2 | * purple |
|
17666
9c32c365b852
Pretend that WSAEINPROGRESS is EAGAIN (for our purposes, I think they are equivalent). I think this might help #485. References #485.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
3 | * |
|
5913
4d016c00bb36
[gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents:
5474
diff
changeset
|
4 | * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> |
|
4d016c00bb36
[gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents:
5474
diff
changeset
|
5 | * |
|
4d016c00bb36
[gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents:
5474
diff
changeset
|
6 | * This program is free software; you can redistribute it and/or modify |
|
4d016c00bb36
[gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents:
5474
diff
changeset
|
7 | * it under the terms of the GNU General Public License as published by |
|
4d016c00bb36
[gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents:
5474
diff
changeset
|
8 | * the Free Software Foundation; either version 2 of the License, or |
|
4d016c00bb36
[gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents:
5474
diff
changeset
|
9 | * (at your option) any later version. |
|
4d016c00bb36
[gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents:
5474
diff
changeset
|
10 | * |
|
4d016c00bb36
[gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents:
5474
diff
changeset
|
11 | * This program is distributed in the hope that it will be useful, |
|
4d016c00bb36
[gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents:
5474
diff
changeset
|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
4d016c00bb36
[gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents:
5474
diff
changeset
|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
4d016c00bb36
[gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents:
5474
diff
changeset
|
14 | * GNU General Public License for more details. |
|
4d016c00bb36
[gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents:
5474
diff
changeset
|
15 | * |
|
4d016c00bb36
[gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents:
5474
diff
changeset
|
16 | * You should have received a copy of the GNU General Public License |
|
4d016c00bb36
[gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents:
5474
diff
changeset
|
17 | * along with this program; if not, write to the Free Software |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18553
diff
changeset
|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
5913
4d016c00bb36
[gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents:
5474
diff
changeset
|
19 | * |
| 3712 | 20 | */ |
|
35892
02bf3200b9cb
cross-win32: make use of WIN32_LEAN_AND_MEAN define
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35855
diff
changeset
|
21 | |
|
02bf3200b9cb
cross-win32: make use of WIN32_LEAN_AND_MEAN define
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35855
diff
changeset
|
22 | #include <config.h> |
|
02bf3200b9cb
cross-win32: make use of WIN32_LEAN_AND_MEAN define
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35855
diff
changeset
|
23 | |
|
39373
47667f5c6696
libpurple: Include 'glib/gi18n-lib.h' instead of 'libintl.h'
Mike Ruprecht <cmaiku@gmail.com>
parents:
39020
diff
changeset
|
24 | #include <glib/gi18n-lib.h> |
|
8244
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
25 | #include <winsock2.h> |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
26 | #include <ws2tcpip.h> |
|
3777
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
27 | #include <io.h> |
| 3712 | 28 | #include <stdlib.h> |
|
3777
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
29 | #include <stdio.h> |
| 3712 | 30 | #include <errno.h> |
|
3777
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
31 | #include <sys/timeb.h> |
|
4905
1464e05926f0
[gaim-migrate @ 5239]
Herman Bloggs <herman@bluedigits.com>
parents:
4193
diff
changeset
|
32 | #include <sys/stat.h> |
|
3777
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
33 | #include <time.h> |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
9611
diff
changeset
|
34 | #include <glib.h> |
|
6425
3e86c949c98a
[gaim-migrate @ 6933]
Herman Bloggs <herman@bluedigits.com>
parents:
5913
diff
changeset
|
35 | #include "debug.h" |
|
3777
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
36 | #include "libc_internal.h" |
|
38688
79304d0f6d43
Fix mingw32 compilation
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
38259
diff
changeset
|
37 | #include "util.h" |
|
25333
182125d7b7fc
Fix from the QuteCom folks to compile with Glib < 2.8.5 with MSVC. Fixes #7761. Also some minor cleanup from me.
Daniel Atallah <datallah@pidgin.im>
parents:
24843
diff
changeset
|
38 | #include <glib/gstdio.h> |
|
38604
9ad76b0d9de7
win32/libc_interface: Add missing util.h include for purple_strequal()
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
39 | #include "util.h" |
| 3712 | 40 | |
|
25333
182125d7b7fc
Fix from the QuteCom folks to compile with Glib < 2.8.5 with MSVC. Fixes #7761. Also some minor cleanup from me.
Daniel Atallah <datallah@pidgin.im>
parents:
24843
diff
changeset
|
41 | #ifndef S_ISDIR |
|
182125d7b7fc
Fix from the QuteCom folks to compile with Glib < 2.8.5 with MSVC. Fixes #7761. Also some minor cleanup from me.
Daniel Atallah <datallah@pidgin.im>
parents:
24843
diff
changeset
|
42 | # define S_ISDIR(m) (((m)&S_IFDIR)==S_IFDIR) |
|
182125d7b7fc
Fix from the QuteCom folks to compile with Glib < 2.8.5 with MSVC. Fixes #7761. Also some minor cleanup from me.
Daniel Atallah <datallah@pidgin.im>
parents:
24843
diff
changeset
|
43 | #endif |
|
21771
0df7285a6164
Better error messages for common Winsock errors. This was Kevin's wonderful idea.
Daniel Atallah <datallah@pidgin.im>
parents:
21635
diff
changeset
|
44 | |
| 3712 | 45 | static char errbuf[1024]; |
| 46 | ||
| 47 | /* helpers */ | |
| 15884 | 48 | static int wpurple_is_socket( int fd ) { |
| 3712 | 49 | int optval; |
| 29797 | 50 | int optlen = sizeof(int); |
| 3712 | 51 | |
| 52 | if( (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void*)&optval, &optlen)) == SOCKET_ERROR ) { | |
| 53 | int error = WSAGetLastError(); | |
| 54 | if( error == WSAENOTSOCK ) | |
| 55 | return FALSE; | |
| 56 | else { | |
| 15884 | 57 | purple_debug(PURPLE_DEBUG_WARNING, "wpurple", "wpurple_is_socket: getsockopt returned error: %d\n", error); |
| 3712 | 58 | return FALSE; |
| 59 | } | |
| 60 | } | |
| 61 | return TRUE; | |
| 62 | } | |
| 63 | ||
| 64 | /* socket.h */ | |
| 15884 | 65 | int wpurple_socket (int namespace, int style, int protocol) { |
| 3712 | 66 | int ret; |
| 67 | ||
| 68 | ret = socket( namespace, style, protocol ); | |
| 69 | ||
|
35855
3e60f9385431
cross-win32: libpurple builds now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33884
diff
changeset
|
70 | if (ret == (int)INVALID_SOCKET) { |
| 3712 | 71 | errno = WSAGetLastError(); |
| 72 | return -1; | |
| 73 | } | |
| 74 | return ret; | |
| 75 | } | |
| 76 | ||
| 15884 | 77 | int wpurple_connect(int socket, struct sockaddr *addr, u_long length) { |
| 3712 | 78 | int ret; |
| 79 | ||
| 80 | ret = connect( socket, addr, length ); | |
|
17666
9c32c365b852
Pretend that WSAEINPROGRESS is EAGAIN (for our purposes, I think they are equivalent). I think this might help #485. References #485.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
81 | |
| 3712 | 82 | if( ret == SOCKET_ERROR ) { |
| 83 | errno = WSAGetLastError(); | |
| 84 | if( errno == WSAEWOULDBLOCK ) | |
| 85 | errno = WSAEINPROGRESS; | |
| 86 | return -1; | |
| 87 | } | |
| 88 | return 0; | |
| 89 | } | |
| 90 | ||
| 15884 | 91 | int wpurple_getsockopt(int socket, int level, int optname, void *optval, socklen_t *optlenptr) { |
|
8244
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
92 | if(getsockopt(socket, level, optname, optval, optlenptr) == SOCKET_ERROR ) { |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
93 | errno = WSAGetLastError(); |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
94 | return -1; |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
95 | } |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
96 | return 0; |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
97 | } |
| 3712 | 98 | |
| 15884 | 99 | int wpurple_setsockopt(int socket, int level, int optname, const void *optval, socklen_t optlen) { |
|
8244
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
100 | if(setsockopt(socket, level, optname, optval, optlen) == SOCKET_ERROR ) { |
| 3712 | 101 | errno = WSAGetLastError(); |
| 102 | return -1; | |
| 103 | } | |
|
8244
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
104 | return 0; |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
105 | } |
| 3712 | 106 | |
| 15884 | 107 | int wpurple_getsockname(int socket, struct sockaddr *addr, socklen_t *lenptr) { |
|
8244
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
108 | if(getsockname(socket, addr, lenptr) == SOCKET_ERROR) { |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
109 | errno = WSAGetLastError(); |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
110 | return -1; |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
111 | } |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
112 | return 0; |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
113 | } |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
114 | |
| 15884 | 115 | int wpurple_bind(int socket, struct sockaddr *addr, socklen_t length) { |
|
8244
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
116 | if(bind(socket, addr, length) == SOCKET_ERROR) { |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
117 | errno = WSAGetLastError(); |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
118 | return -1; |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
119 | } |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
120 | return 0; |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
121 | } |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
122 | |
| 15884 | 123 | int wpurple_listen(int socket, unsigned int n) { |
|
8244
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
124 | if(listen(socket, n) == SOCKET_ERROR) { |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
125 | errno = WSAGetLastError(); |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
126 | return -1; |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
127 | } |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
128 | return 0; |
| 3712 | 129 | } |
| 130 | ||
| 15884 | 131 | int wpurple_sendto(int socket, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) { |
|
11431
60971f504319
[gaim-migrate @ 13668]
Daniel Atallah <datallah@pidgin.im>
parents:
11364
diff
changeset
|
132 | int ret; |
|
60971f504319
[gaim-migrate @ 13668]
Daniel Atallah <datallah@pidgin.im>
parents:
11364
diff
changeset
|
133 | if ((ret = sendto(socket, buf, len, flags, to, tolen) |
|
60971f504319
[gaim-migrate @ 13668]
Daniel Atallah <datallah@pidgin.im>
parents:
11364
diff
changeset
|
134 | ) == SOCKET_ERROR) { |
|
60971f504319
[gaim-migrate @ 13668]
Daniel Atallah <datallah@pidgin.im>
parents:
11364
diff
changeset
|
135 | errno = WSAGetLastError(); |
|
17666
9c32c365b852
Pretend that WSAEINPROGRESS is EAGAIN (for our purposes, I think they are equivalent). I think this might help #485. References #485.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
136 | if(errno == WSAEWOULDBLOCK || errno == WSAEINPROGRESS) |
|
9c32c365b852
Pretend that WSAEINPROGRESS is EAGAIN (for our purposes, I think they are equivalent). I think this might help #485. References #485.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
137 | errno = EAGAIN; |
|
11431
60971f504319
[gaim-migrate @ 13668]
Daniel Atallah <datallah@pidgin.im>
parents:
11364
diff
changeset
|
138 | return -1; |
|
60971f504319
[gaim-migrate @ 13668]
Daniel Atallah <datallah@pidgin.im>
parents:
11364
diff
changeset
|
139 | } |
|
60971f504319
[gaim-migrate @ 13668]
Daniel Atallah <datallah@pidgin.im>
parents:
11364
diff
changeset
|
140 | return ret; |
|
60971f504319
[gaim-migrate @ 13668]
Daniel Atallah <datallah@pidgin.im>
parents:
11364
diff
changeset
|
141 | } |
|
60971f504319
[gaim-migrate @ 13668]
Daniel Atallah <datallah@pidgin.im>
parents:
11364
diff
changeset
|
142 | |
| 3712 | 143 | /* fcntl.h */ |
| 144 | /* This is not a full implementation of fcntl. Update as needed.. */ | |
|
20239
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
145 | int wpurple_fcntl(int socket, int command, ...) { |
|
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
146 | |
| 3712 | 147 | switch( command ) { |
|
20239
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
148 | case F_GETFL: |
|
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
149 | return 0; |
|
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
150 | |
| 3712 | 151 | case F_SETFL: |
| 152 | { | |
|
20239
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
153 | va_list args; |
|
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
154 | int val; |
| 3712 | 155 | int ret=0; |
| 156 | ||
|
20239
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
157 | va_start(args, command); |
|
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
158 | val = va_arg(args, int); |
|
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
159 | va_end(args); |
|
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
160 | |
| 3712 | 161 | switch( val ) { |
| 162 | case O_NONBLOCK: | |
| 163 | { | |
| 164 | u_long imode=1; | |
| 165 | ret = ioctlsocket(socket, FIONBIO, &imode); | |
| 166 | break; | |
| 167 | } | |
| 168 | case 0: | |
|
20239
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
169 | { |
| 3712 | 170 | u_long imode=0; |
| 171 | ret = ioctlsocket(socket, FIONBIO, &imode); | |
| 172 | break; | |
| 173 | } | |
| 174 | default: | |
| 175 | errno = EINVAL; | |
| 176 | return -1; | |
| 177 | }/*end switch*/ | |
| 178 | if( ret == SOCKET_ERROR ) { | |
| 179 | errno = WSAGetLastError(); | |
| 180 | return -1; | |
| 181 | } | |
| 182 | return 0; | |
| 183 | } | |
| 184 | default: | |
| 15884 | 185 | purple_debug(PURPLE_DEBUG_WARNING, "wpurple", "wpurple_fcntl: Unsupported command\n"); |
| 3712 | 186 | return -1; |
| 187 | }/*end switch*/ | |
| 188 | } | |
| 189 | ||
| 190 | /* sys/ioctl.h */ | |
| 15884 | 191 | int wpurple_ioctl(int fd, int command, void* val) { |
| 3712 | 192 | switch( command ) { |
| 193 | case FIONBIO: | |
| 194 | { | |
| 195 | if (ioctlsocket(fd, FIONBIO, (unsigned long *)val) == SOCKET_ERROR) { | |
| 196 | errno = WSAGetLastError(); | |
| 197 | return -1; | |
| 198 | } | |
| 199 | return 0; | |
| 200 | } | |
|
11364
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
201 | case SIOCGIFCONF: |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
202 | { |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
203 | INTERFACE_INFO InterfaceList[20]; |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
204 | unsigned long nBytesReturned; |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
205 | if (WSAIoctl(fd, SIO_GET_INTERFACE_LIST, |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
206 | 0, 0, &InterfaceList, |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
207 | sizeof(InterfaceList), &nBytesReturned, |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
208 | 0, 0) == SOCKET_ERROR) { |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
209 | errno = WSAGetLastError(); |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
210 | return -1; |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
211 | } else { |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
212 | int i; |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
213 | struct ifconf *ifc = val; |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
214 | char *tmp = ifc->ifc_buf; |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
215 | int nNumInterfaces = |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
216 | nBytesReturned / sizeof(INTERFACE_INFO); |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
217 | for (i = 0; i < nNumInterfaces; i++) { |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
218 | INTERFACE_INFO ii = InterfaceList[i]; |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
219 | struct ifreq *ifr = (struct ifreq *) tmp; |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
220 | struct sockaddr_in *sa = (struct sockaddr_in *) &ifr->ifr_addr; |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
221 | |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
222 | sa->sin_family = ii.iiAddress.AddressIn.sin_family; |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
223 | sa->sin_port = ii.iiAddress.AddressIn.sin_port; |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
224 | sa->sin_addr.s_addr = ii.iiAddress.AddressIn.sin_addr.s_addr; |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
225 | tmp += sizeof(struct ifreq); |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
226 | |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
227 | /* Make sure that we can fit in the original buffer */ |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
228 | if (tmp >= (ifc->ifc_buf + ifc->ifc_len + sizeof(struct ifreq))) { |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
229 | break; |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
230 | } |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
231 | } |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
232 | /* Replace the length with the actually used length */ |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
233 | ifc->ifc_len = ifc->ifc_len - (ifc->ifc_buf - tmp); |
|
12488
72878a4bf35a
[gaim-migrate @ 14800]
Daniel Atallah <datallah@pidgin.im>
parents:
11543
diff
changeset
|
234 | return 0; |
|
11364
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
235 | } |
|
d754cf40ec4b
[gaim-migrate @ 13588]
Daniel Atallah <datallah@pidgin.im>
parents:
10601
diff
changeset
|
236 | } |
| 3712 | 237 | default: |
| 238 | errno = EINVAL; | |
| 239 | return -1; | |
| 240 | }/*end switch*/ | |
| 241 | } | |
| 242 | ||
| 243 | /* arpa/inet.h */ | |
| 15884 | 244 | int wpurple_inet_aton(const char *name, struct in_addr *addr) { |
| 3712 | 245 | if((addr->s_addr = inet_addr(name)) == INADDR_NONE) |
| 246 | return 0; | |
| 247 | else | |
| 248 | return 1; | |
| 249 | } | |
| 250 | ||
|
14974
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
251 | /* Thanks to GNU wget for this inet_ntop() implementation */ |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
252 | const char * |
| 15884 | 253 | wpurple_inet_ntop (int af, const void *src, char *dst, socklen_t cnt) |
|
14974
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
254 | { |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
255 | /* struct sockaddr can't accomodate struct sockaddr_in6. */ |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
256 | union { |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
257 | struct sockaddr_in6 sin6; |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
258 | struct sockaddr_in sin; |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
259 | } sa; |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
260 | DWORD dstlen = cnt; |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
261 | size_t srcsize; |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
262 | |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
263 | ZeroMemory(&sa, sizeof(sa)); |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
264 | switch (af) |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
265 | { |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
266 | case AF_INET: |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
267 | sa.sin.sin_family = AF_INET; |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
268 | sa.sin.sin_addr = *(struct in_addr *) src; |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
269 | srcsize = sizeof (sa.sin); |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
270 | break; |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
271 | case AF_INET6: |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
272 | sa.sin6.sin6_family = AF_INET6; |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
273 | sa.sin6.sin6_addr = *(struct in6_addr *) src; |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
274 | srcsize = sizeof (sa.sin6); |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
275 | break; |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
276 | default: |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
277 | abort (); |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
278 | } |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
279 | |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
280 | if (WSAAddressToString ((struct sockaddr *) &sa, srcsize, NULL, dst, &dstlen) != 0) |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
281 | { |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
282 | errno = WSAGetLastError(); |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
283 | return NULL; |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
284 | } |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
285 | return (const char *) dst; |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
286 | } |
|
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
287 | |
|
32069
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
288 | int |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
289 | wpurple_inet_pton(int af, const char *src, void *dst) |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
290 | { |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
291 | /* struct sockaddr can't accomodate struct sockaddr_in6. */ |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
292 | union { |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
293 | struct sockaddr_in6 sin6; |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
294 | struct sockaddr_in sin; |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
295 | } sa; |
|
33884
3fd1628aa718
Fixing warnings (win32, glib, others)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32744
diff
changeset
|
296 | int srcsize; |
|
32069
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
297 | |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
298 | switch(af) |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
299 | { |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
300 | case AF_INET: |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
301 | sa.sin.sin_family = AF_INET; |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
302 | srcsize = sizeof (sa.sin); |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
303 | break; |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
304 | case AF_INET6: |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
305 | sa.sin6.sin6_family = AF_INET6; |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
306 | srcsize = sizeof (sa.sin6); |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
307 | break; |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
308 | default: |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
309 | errno = WSAEPFNOSUPPORT; |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
310 | return -1; |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
311 | } |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
312 | |
|
33884
3fd1628aa718
Fixing warnings (win32, glib, others)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32744
diff
changeset
|
313 | if (WSAStringToAddress((LPTSTR)src, af, NULL, (struct sockaddr *) &sa, &srcsize) != 0) |
|
32069
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
314 | { |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
315 | errno = WSAGetLastError(); |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
316 | return -1; |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
317 | } |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
318 | |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
319 | switch(af) |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
320 | { |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
321 | case AF_INET: |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
322 | memcpy(dst, &sa.sin.sin_addr, sizeof(sa.sin.sin_addr)); |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
323 | break; |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
324 | case AF_INET6: |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
325 | memcpy(dst, &sa.sin6.sin6_addr, sizeof(sa.sin6.sin6_addr)); |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
326 | break; |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
327 | } |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
328 | |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
329 | return 1; |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
330 | } |
|
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
31957
diff
changeset
|
331 | |
|
14974
8180f0f2e20c
[gaim-migrate @ 17684]
Daniel Atallah <datallah@pidgin.im>
parents:
14286
diff
changeset
|
332 | |
| 3712 | 333 | /* netdb.h */ |
| 15884 | 334 | struct hostent* wpurple_gethostbyname(const char *name) { |
| 3712 | 335 | struct hostent *hp; |
| 336 | ||
| 337 | if((hp = gethostbyname(name)) == NULL) { | |
| 338 | errno = WSAGetLastError(); | |
| 339 | return NULL; | |
| 340 | } | |
| 341 | return hp; | |
| 342 | } | |
| 343 | ||
| 344 | /* string.h */ | |
|
21771
0df7285a6164
Better error messages for common Winsock errors. This was Kevin's wonderful idea.
Daniel Atallah <datallah@pidgin.im>
parents:
21635
diff
changeset
|
345 | char* wpurple_strerror(int errornum) { |
|
0df7285a6164
Better error messages for common Winsock errors. This was Kevin's wonderful idea.
Daniel Atallah <datallah@pidgin.im>
parents:
21635
diff
changeset
|
346 | if (errornum > WSABASEERR) { |
|
0df7285a6164
Better error messages for common Winsock errors. This was Kevin's wonderful idea.
Daniel Atallah <datallah@pidgin.im>
parents:
21635
diff
changeset
|
347 | switch(errornum) { |
|
0df7285a6164
Better error messages for common Winsock errors. This was Kevin's wonderful idea.
Daniel Atallah <datallah@pidgin.im>
parents:
21635
diff
changeset
|
348 | case WSAECONNABORTED: /* 10053 */ |
|
30792
155b65d26118
Fix some cases where an arbitrary string was being specified as a printf format.
Daniel Atallah <datallah@pidgin.im>
parents:
29797
diff
changeset
|
349 | g_snprintf(errbuf, sizeof(errbuf), "%s", _("Connection interrupted by other software on your computer.")); |
|
22641
c5e5a10e4799
I was wondering why the more sane error messges were never appearing... now I know. There is also a fix here that uses glib's internal rename stuff on recent versions because it is more robust than our win32 version.
Daniel Atallah <datallah@pidgin.im>
parents:
21771
diff
changeset
|
350 | break; |
|
21771
0df7285a6164
Better error messages for common Winsock errors. This was Kevin's wonderful idea.
Daniel Atallah <datallah@pidgin.im>
parents:
21635
diff
changeset
|
351 | case WSAECONNRESET: /* 10054 */ |
|
30792
155b65d26118
Fix some cases where an arbitrary string was being specified as a printf format.
Daniel Atallah <datallah@pidgin.im>
parents:
29797
diff
changeset
|
352 | g_snprintf(errbuf, sizeof(errbuf), "%s", _("Remote host closed connection.")); |
|
22641
c5e5a10e4799
I was wondering why the more sane error messges were never appearing... now I know. There is also a fix here that uses glib's internal rename stuff on recent versions because it is more robust than our win32 version.
Daniel Atallah <datallah@pidgin.im>
parents:
21771
diff
changeset
|
353 | break; |
|
21771
0df7285a6164
Better error messages for common Winsock errors. This was Kevin's wonderful idea.
Daniel Atallah <datallah@pidgin.im>
parents:
21635
diff
changeset
|
354 | case WSAETIMEDOUT: /* 10060 */ |
|
30792
155b65d26118
Fix some cases where an arbitrary string was being specified as a printf format.
Daniel Atallah <datallah@pidgin.im>
parents:
29797
diff
changeset
|
355 | g_snprintf(errbuf, sizeof(errbuf), "%s", _("Connection timed out.")); |
|
22641
c5e5a10e4799
I was wondering why the more sane error messges were never appearing... now I know. There is also a fix here that uses glib's internal rename stuff on recent versions because it is more robust than our win32 version.
Daniel Atallah <datallah@pidgin.im>
parents:
21771
diff
changeset
|
356 | break; |
|
23883
222e2f637efd
Fix running several Bonjour instances on the same machine.
Daniel Atallah <datallah@pidgin.im>
parents:
22871
diff
changeset
|
357 | case WSAECONNREFUSED: /* 10061 */ |
|
30792
155b65d26118
Fix some cases where an arbitrary string was being specified as a printf format.
Daniel Atallah <datallah@pidgin.im>
parents:
29797
diff
changeset
|
358 | g_snprintf(errbuf, sizeof(errbuf), "%s", _("Connection refused.")); |
|
22641
c5e5a10e4799
I was wondering why the more sane error messges were never appearing... now I know. There is also a fix here that uses glib's internal rename stuff on recent versions because it is more robust than our win32 version.
Daniel Atallah <datallah@pidgin.im>
parents:
21771
diff
changeset
|
359 | break; |
|
23883
222e2f637efd
Fix running several Bonjour instances on the same machine.
Daniel Atallah <datallah@pidgin.im>
parents:
22871
diff
changeset
|
360 | case WSAEADDRINUSE: /* 10048 */ |
|
30792
155b65d26118
Fix some cases where an arbitrary string was being specified as a printf format.
Daniel Atallah <datallah@pidgin.im>
parents:
29797
diff
changeset
|
361 | g_snprintf(errbuf, sizeof(errbuf), "%s", _("Address already in use.")); |
|
23883
222e2f637efd
Fix running several Bonjour instances on the same machine.
Daniel Atallah <datallah@pidgin.im>
parents:
22871
diff
changeset
|
362 | break; |
|
21771
0df7285a6164
Better error messages for common Winsock errors. This was Kevin's wonderful idea.
Daniel Atallah <datallah@pidgin.im>
parents:
21635
diff
changeset
|
363 | default: |
|
22871
a5ba9f9d340a
Use g_snprintf() instead of snprintf(), which isn't really available on
Daniel Atallah <datallah@pidgin.im>
parents:
22641
diff
changeset
|
364 | g_snprintf(errbuf, sizeof(errbuf), "Windows socket error #%d", errornum); |
|
21771
0df7285a6164
Better error messages for common Winsock errors. This was Kevin's wonderful idea.
Daniel Atallah <datallah@pidgin.im>
parents:
21635
diff
changeset
|
365 | } |
|
0df7285a6164
Better error messages for common Winsock errors. This was Kevin's wonderful idea.
Daniel Atallah <datallah@pidgin.im>
parents:
21635
diff
changeset
|
366 | } else { |
|
0df7285a6164
Better error messages for common Winsock errors. This was Kevin's wonderful idea.
Daniel Atallah <datallah@pidgin.im>
parents:
21635
diff
changeset
|
367 | const char *tmp = g_strerror(errornum); |
|
30792
155b65d26118
Fix some cases where an arbitrary string was being specified as a printf format.
Daniel Atallah <datallah@pidgin.im>
parents:
29797
diff
changeset
|
368 | g_snprintf(errbuf, sizeof(errbuf), "%s", tmp); |
| 3712 | 369 | } |
|
21771
0df7285a6164
Better error messages for common Winsock errors. This was Kevin's wonderful idea.
Daniel Atallah <datallah@pidgin.im>
parents:
21635
diff
changeset
|
370 | return errbuf; |
| 3712 | 371 | } |
| 372 | ||
| 373 | /* unistd.h */ | |
| 374 | ||
| 375 | /* | |
| 376 | * We need to figure out whether fd is a file or socket handle. | |
| 377 | */ | |
| 15884 | 378 | int wpurple_read(int fd, void *buf, unsigned int size) { |
| 3712 | 379 | int ret; |
| 380 | ||
|
24843
ab68c6d3c247
(Slightly modified) patch from fqueze to avoid exceptions with newer win32 CRTs.
Daniel Atallah <datallah@pidgin.im>
parents:
23883
diff
changeset
|
381 | if (fd < 0) { |
|
ab68c6d3c247
(Slightly modified) patch from fqueze to avoid exceptions with newer win32 CRTs.
Daniel Atallah <datallah@pidgin.im>
parents:
23883
diff
changeset
|
382 | errno = EBADF; |
|
ab68c6d3c247
(Slightly modified) patch from fqueze to avoid exceptions with newer win32 CRTs.
Daniel Atallah <datallah@pidgin.im>
parents:
23883
diff
changeset
|
383 | g_return_val_if_reached(-1); |
|
ab68c6d3c247
(Slightly modified) patch from fqueze to avoid exceptions with newer win32 CRTs.
Daniel Atallah <datallah@pidgin.im>
parents:
23883
diff
changeset
|
384 | } |
|
ab68c6d3c247
(Slightly modified) patch from fqueze to avoid exceptions with newer win32 CRTs.
Daniel Atallah <datallah@pidgin.im>
parents:
23883
diff
changeset
|
385 | |
| 15884 | 386 | if(wpurple_is_socket(fd)) { |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12749
diff
changeset
|
387 | if((ret = recv(fd, buf, size, 0)) == SOCKET_ERROR) { |
| 3712 | 388 | errno = WSAGetLastError(); |
|
17666
9c32c365b852
Pretend that WSAEINPROGRESS is EAGAIN (for our purposes, I think they are equivalent). I think this might help #485. References #485.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
389 | if(errno == WSAEWOULDBLOCK || errno == WSAEINPROGRESS) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12749
diff
changeset
|
390 | errno = EAGAIN; |
| 3712 | 391 | return -1; |
| 392 | } | |
| 393 | else { | |
| 394 | /* success reading socket */ | |
| 395 | return ret; | |
| 396 | } | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12749
diff
changeset
|
397 | } else { |
| 3712 | 398 | /* fd is not a socket handle.. pass it off to read */ |
|
22871
a5ba9f9d340a
Use g_snprintf() instead of snprintf(), which isn't really available on
Daniel Atallah <datallah@pidgin.im>
parents:
22641
diff
changeset
|
399 | return _read(fd, buf, size); |
| 3712 | 400 | } |
| 401 | } | |
| 402 | ||
| 15884 | 403 | int wpurple_send(int fd, const void *buf, unsigned int size, int flags) { |
| 3712 | 404 | int ret; |
| 405 | ||
|
13780
f642a0729daa
[gaim-migrate @ 16190]
Daniel Atallah <datallah@pidgin.im>
parents:
13371
diff
changeset
|
406 | ret = send(fd, buf, size, flags); |
|
f642a0729daa
[gaim-migrate @ 16190]
Daniel Atallah <datallah@pidgin.im>
parents:
13371
diff
changeset
|
407 | |
|
f642a0729daa
[gaim-migrate @ 16190]
Daniel Atallah <datallah@pidgin.im>
parents:
13371
diff
changeset
|
408 | if (ret == SOCKET_ERROR) { |
|
f642a0729daa
[gaim-migrate @ 16190]
Daniel Atallah <datallah@pidgin.im>
parents:
13371
diff
changeset
|
409 | errno = WSAGetLastError(); |
|
17666
9c32c365b852
Pretend that WSAEINPROGRESS is EAGAIN (for our purposes, I think they are equivalent). I think this might help #485. References #485.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
410 | if(errno == WSAEWOULDBLOCK || errno == WSAEINPROGRESS) |
|
13780
f642a0729daa
[gaim-migrate @ 16190]
Daniel Atallah <datallah@pidgin.im>
parents:
13371
diff
changeset
|
411 | errno = EAGAIN; |
|
f642a0729daa
[gaim-migrate @ 16190]
Daniel Atallah <datallah@pidgin.im>
parents:
13371
diff
changeset
|
412 | return -1; |
|
f642a0729daa
[gaim-migrate @ 16190]
Daniel Atallah <datallah@pidgin.im>
parents:
13371
diff
changeset
|
413 | } |
|
f642a0729daa
[gaim-migrate @ 16190]
Daniel Atallah <datallah@pidgin.im>
parents:
13371
diff
changeset
|
414 | return ret; |
|
f642a0729daa
[gaim-migrate @ 16190]
Daniel Atallah <datallah@pidgin.im>
parents:
13371
diff
changeset
|
415 | } |
|
f642a0729daa
[gaim-migrate @ 16190]
Daniel Atallah <datallah@pidgin.im>
parents:
13371
diff
changeset
|
416 | |
| 15884 | 417 | int wpurple_write(int fd, const void *buf, unsigned int size) { |
|
13780
f642a0729daa
[gaim-migrate @ 16190]
Daniel Atallah <datallah@pidgin.im>
parents:
13371
diff
changeset
|
418 | |
|
24843
ab68c6d3c247
(Slightly modified) patch from fqueze to avoid exceptions with newer win32 CRTs.
Daniel Atallah <datallah@pidgin.im>
parents:
23883
diff
changeset
|
419 | if (fd < 0) { |
|
ab68c6d3c247
(Slightly modified) patch from fqueze to avoid exceptions with newer win32 CRTs.
Daniel Atallah <datallah@pidgin.im>
parents:
23883
diff
changeset
|
420 | errno = EBADF; |
|
ab68c6d3c247
(Slightly modified) patch from fqueze to avoid exceptions with newer win32 CRTs.
Daniel Atallah <datallah@pidgin.im>
parents:
23883
diff
changeset
|
421 | g_return_val_if_reached(-1); |
|
ab68c6d3c247
(Slightly modified) patch from fqueze to avoid exceptions with newer win32 CRTs.
Daniel Atallah <datallah@pidgin.im>
parents:
23883
diff
changeset
|
422 | } |
|
ab68c6d3c247
(Slightly modified) patch from fqueze to avoid exceptions with newer win32 CRTs.
Daniel Atallah <datallah@pidgin.im>
parents:
23883
diff
changeset
|
423 | |
| 15884 | 424 | if(wpurple_is_socket(fd)) |
| 425 | return wpurple_send(fd, buf, size, 0); | |
|
13780
f642a0729daa
[gaim-migrate @ 16190]
Daniel Atallah <datallah@pidgin.im>
parents:
13371
diff
changeset
|
426 | else |
|
22871
a5ba9f9d340a
Use g_snprintf() instead of snprintf(), which isn't really available on
Daniel Atallah <datallah@pidgin.im>
parents:
22641
diff
changeset
|
427 | return _write(fd, buf, size); |
| 3712 | 428 | } |
| 429 | ||
| 15884 | 430 | int wpurple_recv(int fd, void *buf, size_t len, int flags) { |
|
12749
704b51d5007a
[gaim-migrate @ 15096]
Daniel Atallah <datallah@pidgin.im>
parents:
12488
diff
changeset
|
431 | int ret; |
|
704b51d5007a
[gaim-migrate @ 15096]
Daniel Atallah <datallah@pidgin.im>
parents:
12488
diff
changeset
|
432 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12749
diff
changeset
|
433 | if((ret = recv(fd, buf, len, flags)) == SOCKET_ERROR) { |
|
12749
704b51d5007a
[gaim-migrate @ 15096]
Daniel Atallah <datallah@pidgin.im>
parents:
12488
diff
changeset
|
434 | errno = WSAGetLastError(); |
|
17666
9c32c365b852
Pretend that WSAEINPROGRESS is EAGAIN (for our purposes, I think they are equivalent). I think this might help #485. References #485.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
435 | if(errno == WSAEWOULDBLOCK || errno == WSAEINPROGRESS) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12749
diff
changeset
|
436 | errno = EAGAIN; |
|
12749
704b51d5007a
[gaim-migrate @ 15096]
Daniel Atallah <datallah@pidgin.im>
parents:
12488
diff
changeset
|
437 | return -1; |
|
704b51d5007a
[gaim-migrate @ 15096]
Daniel Atallah <datallah@pidgin.im>
parents:
12488
diff
changeset
|
438 | } else { |
|
704b51d5007a
[gaim-migrate @ 15096]
Daniel Atallah <datallah@pidgin.im>
parents:
12488
diff
changeset
|
439 | return ret; |
|
704b51d5007a
[gaim-migrate @ 15096]
Daniel Atallah <datallah@pidgin.im>
parents:
12488
diff
changeset
|
440 | } |
|
704b51d5007a
[gaim-migrate @ 15096]
Daniel Atallah <datallah@pidgin.im>
parents:
12488
diff
changeset
|
441 | } |
|
704b51d5007a
[gaim-migrate @ 15096]
Daniel Atallah <datallah@pidgin.im>
parents:
12488
diff
changeset
|
442 | |
| 15884 | 443 | int wpurple_close(int fd) { |
| 3712 | 444 | int ret; |
| 445 | ||
|
24843
ab68c6d3c247
(Slightly modified) patch from fqueze to avoid exceptions with newer win32 CRTs.
Daniel Atallah <datallah@pidgin.im>
parents:
23883
diff
changeset
|
446 | if (fd < 0) { |
|
ab68c6d3c247
(Slightly modified) patch from fqueze to avoid exceptions with newer win32 CRTs.
Daniel Atallah <datallah@pidgin.im>
parents:
23883
diff
changeset
|
447 | errno = EBADF; |
|
ab68c6d3c247
(Slightly modified) patch from fqueze to avoid exceptions with newer win32 CRTs.
Daniel Atallah <datallah@pidgin.im>
parents:
23883
diff
changeset
|
448 | g_return_val_if_reached(-1); |
|
ab68c6d3c247
(Slightly modified) patch from fqueze to avoid exceptions with newer win32 CRTs.
Daniel Atallah <datallah@pidgin.im>
parents:
23883
diff
changeset
|
449 | } |
|
ab68c6d3c247
(Slightly modified) patch from fqueze to avoid exceptions with newer win32 CRTs.
Daniel Atallah <datallah@pidgin.im>
parents:
23883
diff
changeset
|
450 | |
| 15884 | 451 | if( wpurple_is_socket(fd) ) { |
| 3712 | 452 | if( (ret = closesocket(fd)) == SOCKET_ERROR ) { |
| 453 | errno = WSAGetLastError(); | |
| 454 | return -1; | |
| 455 | } | |
| 456 | else | |
| 457 | return 0; | |
| 458 | } | |
| 459 | else | |
|
22871
a5ba9f9d340a
Use g_snprintf() instead of snprintf(), which isn't really available on
Daniel Atallah <datallah@pidgin.im>
parents:
22641
diff
changeset
|
460 | return _close(fd); |
| 3712 | 461 | } |
|
3777
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
462 | |
| 15884 | 463 | int wpurple_gethostname(char *name, size_t size) { |
|
8244
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
464 | if(gethostname(name, size) == SOCKET_ERROR) { |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
465 | errno = WSAGetLastError(); |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
466 | return -1; |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
467 | } |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
468 | return 0; |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
469 | } |
|
014ff38feea9
[gaim-migrate @ 8967]
Herman Bloggs <herman@bluedigits.com>
parents:
6425
diff
changeset
|
470 | |
|
3777
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
471 | /* sys/time.h */ |
|
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
472 | |
| 15884 | 473 | int wpurple_gettimeofday(struct timeval *p, struct timezone *z) { |
|
3777
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
474 | int res = 0; |
|
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
475 | struct _timeb timebuffer; |
|
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
476 | |
|
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
477 | if (z != 0) { |
|
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
478 | _tzset(); |
|
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
479 | z->tz_minuteswest = _timezone/60; |
|
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
480 | z->tz_dsttime = _daylight; |
|
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
481 | } |
|
17666
9c32c365b852
Pretend that WSAEINPROGRESS is EAGAIN (for our purposes, I think they are equivalent). I think this might help #485. References #485.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
482 | |
|
3777
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
483 | if (p != 0) { |
|
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
484 | _ftime(&timebuffer); |
|
21771
0df7285a6164
Better error messages for common Winsock errors. This was Kevin's wonderful idea.
Daniel Atallah <datallah@pidgin.im>
parents:
21635
diff
changeset
|
485 | p->tv_sec = timebuffer.time; /* seconds since 1-1-1970 */ |
|
3777
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
486 | p->tv_usec = timebuffer.millitm*1000; /* microseconds */ |
|
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
487 | } |
|
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
488 | |
|
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
489 | return res; |
|
a3f8adc4c3e0
[gaim-migrate @ 3917]
Herman Bloggs <herman@bluedigits.com>
parents:
3712
diff
changeset
|
490 | } |
|
4905
1464e05926f0
[gaim-migrate @ 5239]
Herman Bloggs <herman@bluedigits.com>
parents:
4193
diff
changeset
|
491 | |
|
5113
8e545faf3d80
[gaim-migrate @ 5476]
Herman Bloggs <herman@bluedigits.com>
parents:
5084
diff
changeset
|
492 | /* time.h */ |
|
8e545faf3d80
[gaim-migrate @ 5476]
Herman Bloggs <herman@bluedigits.com>
parents:
5084
diff
changeset
|
493 | |
| 15884 | 494 | struct tm * wpurple_localtime_r (const time_t *time, struct tm *resultp) { |
|
5113
8e545faf3d80
[gaim-migrate @ 5476]
Herman Bloggs <herman@bluedigits.com>
parents:
5084
diff
changeset
|
495 | struct tm* tmptm; |
|
8e545faf3d80
[gaim-migrate @ 5476]
Herman Bloggs <herman@bluedigits.com>
parents:
5084
diff
changeset
|
496 | |
|
5474
eec4dad3e035
[gaim-migrate @ 5868]
Herman Bloggs <herman@bluedigits.com>
parents:
5113
diff
changeset
|
497 | if(!time) |
|
5913
4d016c00bb36
[gaim-migrate @ 6345]
Herman Bloggs <herman@bluedigits.com>
parents:
5474
diff
changeset
|
498 | return NULL; |
|
5113
8e545faf3d80
[gaim-migrate @ 5476]
Herman Bloggs <herman@bluedigits.com>
parents:
5084
diff
changeset
|
499 | tmptm = localtime(time); |
|
8e545faf3d80
[gaim-migrate @ 5476]
Herman Bloggs <herman@bluedigits.com>
parents:
5084
diff
changeset
|
500 | if(resultp && tmptm) |
|
8e545faf3d80
[gaim-migrate @ 5476]
Herman Bloggs <herman@bluedigits.com>
parents:
5084
diff
changeset
|
501 | return memcpy(resultp, tmptm, sizeof(struct tm)); |
|
8e545faf3d80
[gaim-migrate @ 5476]
Herman Bloggs <herman@bluedigits.com>
parents:
5084
diff
changeset
|
502 | else |
|
8e545faf3d80
[gaim-migrate @ 5476]
Herman Bloggs <herman@bluedigits.com>
parents:
5084
diff
changeset
|
503 | return NULL; |
|
8e545faf3d80
[gaim-migrate @ 5476]
Herman Bloggs <herman@bluedigits.com>
parents:
5084
diff
changeset
|
504 | } |
|
13334
d0d48650f114
[gaim-migrate @ 15703]
Richard Laager <rlaager@pidgin.im>
parents:
13201
diff
changeset
|
505 |