annotate src/win32/libc_interface.c @ 11673:922d0483ca88

[gaim-migrate @ 13959] SF Patch #1326983, from corfe83 'the word "separated" is misspelled as "seperated" when typing gaim --help at the command line.' I'm only committing the change to the code, not to all the .po files. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Sun, 16 Oct 2005 18:18:46 +0000
parents 8be7f4c472cf
children 40fada5b3d59
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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>
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9611
diff changeset
34 #include <glib.h>
6425
26b739bc9f1a [gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
35 #include "debug.h"
3777
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
36 #include "libc_internal.h"
10601
e46b51de549a [gaim-migrate @ 12028]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10589
diff changeset
37 #if GLIB_CHECK_VERSION(2,6,0)
e46b51de549a [gaim-migrate @ 12028]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10589
diff changeset
38 # include <glib/gstdio.h>
e46b51de549a [gaim-migrate @ 12028]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10589
diff changeset
39 #else
e46b51de549a [gaim-migrate @ 12028]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10589
diff changeset
40 #define g_remove remove
e46b51de549a [gaim-migrate @ 12028]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10589
diff changeset
41 #define g_rename rename
e46b51de549a [gaim-migrate @ 12028]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10589
diff changeset
42 #define g_stat stat
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9611
diff changeset
43 #endif
3777
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
44 /*
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
45 * PROTOS
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
46 */
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 /*
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
49 * LOCALS
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
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
52 static char errbuf[1024];
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
53
3777
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
54 /*
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
55 * CODE
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
56 */
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
57
3712
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
58 /* helpers */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
59 static int wgaim_is_socket( int fd ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
60 int optval;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
61 unsigned int optlen = sizeof(int);
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
62
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
63 if( (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void*)&optval, &optlen)) == SOCKET_ERROR ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
64 int error = WSAGetLastError();
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
65 if( error == WSAENOTSOCK )
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
66 return FALSE;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
67 else {
6425
26b739bc9f1a [gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
68 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
69 return FALSE;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
70 }
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 return TRUE;
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
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
75 /* socket.h */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
76 int wgaim_socket (int namespace, int style, int protocol) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
77 int ret;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
78
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
79 ret = socket( namespace, style, protocol );
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 if( ret == INVALID_SOCKET ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
82 errno = WSAGetLastError();
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
83 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
84 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
85 return ret;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
86 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
87
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
88 int wgaim_connect(int socket, struct sockaddr *addr, u_long length) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
89 int ret;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
90
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
91 ret = connect( socket, addr, length );
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
92
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
93 if( ret == SOCKET_ERROR ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
94 errno = WSAGetLastError();
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
95 if( errno == WSAEWOULDBLOCK )
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
96 errno = WSAEINPROGRESS;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
97 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
98 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
99 return 0;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
100 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
101
8244
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
102 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
103 if(getsockopt(socket, level, optname, optval, optlenptr) == SOCKET_ERROR ) {
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
104 errno = WSAGetLastError();
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
105 return -1;
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
106 }
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
107 return 0;
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
108 }
3712
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
109
9611
5e78d07f6b36 [gaim-migrate @ 10454]
Tim Ringenbach <marv@pidgin.im>
parents: 8244
diff changeset
110 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
111 if(setsockopt(socket, level, optname, optval, optlen) == SOCKET_ERROR ) {
3712
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
112 errno = WSAGetLastError();
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
113 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
114 }
8244
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
115 return 0;
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
116 }
3712
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
117
8244
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
118 int wgaim_getsockname(int socket, struct sockaddr *addr, socklen_t *lenptr) {
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
119 if(getsockname(socket, addr, lenptr) == SOCKET_ERROR) {
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
120 errno = WSAGetLastError();
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
121 return -1;
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
122 }
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
123 return 0;
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
124 }
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 int wgaim_bind(int socket, struct sockaddr *addr, socklen_t length) {
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
127 if(bind(socket, addr, length) == SOCKET_ERROR) {
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
128 errno = WSAGetLastError();
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
129 return -1;
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
130 }
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
131 return 0;
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
132 }
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
133
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
134 int wgaim_listen(int socket, unsigned int n) {
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
135 if(listen(socket, n) == SOCKET_ERROR) {
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
136 errno = WSAGetLastError();
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
137 return -1;
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
138 }
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
139 return 0;
3712
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
11431
d2e44c8085e0 [gaim-migrate @ 13668]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11364
diff changeset
142 int wgaim_sendto(int socket, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) {
d2e44c8085e0 [gaim-migrate @ 13668]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11364
diff changeset
143 int ret;
d2e44c8085e0 [gaim-migrate @ 13668]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11364
diff changeset
144 if ((ret = sendto(socket, buf, len, flags, to, tolen)
d2e44c8085e0 [gaim-migrate @ 13668]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11364
diff changeset
145 ) == SOCKET_ERROR) {
d2e44c8085e0 [gaim-migrate @ 13668]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11364
diff changeset
146 errno = WSAGetLastError();
d2e44c8085e0 [gaim-migrate @ 13668]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11364
diff changeset
147 return -1;
d2e44c8085e0 [gaim-migrate @ 13668]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11364
diff changeset
148 }
d2e44c8085e0 [gaim-migrate @ 13668]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11364
diff changeset
149 return ret;
d2e44c8085e0 [gaim-migrate @ 13668]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11364
diff changeset
150 }
d2e44c8085e0 [gaim-migrate @ 13668]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11364
diff changeset
151
3712
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
152 /* fcntl.h */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
153 /* This is not a full implementation of fcntl. Update as needed.. */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
154 int wgaim_fcntl(int socket, int command, int val) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
155 switch( command ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
156 case F_SETFL:
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
157 {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
158 int ret=0;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
159
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
160 switch( val ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
161 case O_NONBLOCK:
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
162 {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
163 u_long imode=1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
164 ret = ioctlsocket(socket, FIONBIO, &imode);
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
165 break;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
166 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
167 case 0:
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
168 {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
169 u_long imode=0;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
170 ret = ioctlsocket(socket, FIONBIO, &imode);
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
171 break;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
172 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
173 default:
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
174 errno = EINVAL;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
175 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
176 }/*end switch*/
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
177 if( ret == 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:
6425
26b739bc9f1a [gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
184 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "wgaim_fcntl: Unsupported command\n");
3712
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 /* sys/ioctl.h */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
190 int wgaim_ioctl(int fd, int command, void* val) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
191 switch( command ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
192 case FIONBIO:
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
193 {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
194 if (ioctlsocket(fd, FIONBIO, (unsigned long *)val) == SOCKET_ERROR) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
195 errno = WSAGetLastError();
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
196 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
197 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
198 return 0;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
199 }
11364
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
200 case SIOCGIFCONF:
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
201 {
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
202 INTERFACE_INFO InterfaceList[20];
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
203 unsigned long nBytesReturned;
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
204 if (WSAIoctl(fd, SIO_GET_INTERFACE_LIST,
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
205 0, 0, &InterfaceList,
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
206 sizeof(InterfaceList), &nBytesReturned,
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
207 0, 0) == SOCKET_ERROR) {
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
208 errno = WSAGetLastError();
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
209 return -1;
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
210 } else {
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
211 int i;
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
212 struct ifconf *ifc = val;
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
213 char *tmp = ifc->ifc_buf;
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
214 int nNumInterfaces =
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
215 nBytesReturned / sizeof(INTERFACE_INFO);
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
216 for (i = 0; i < nNumInterfaces; i++) {
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
217 INTERFACE_INFO ii = InterfaceList[i];
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
218 struct ifreq *ifr = (struct ifreq *) tmp;
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
219 struct sockaddr_in *sa = (struct sockaddr_in *) &ifr->ifr_addr;
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
220
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
221 sa->sin_family = ii.iiAddress.AddressIn.sin_family;
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
222 sa->sin_port = ii.iiAddress.AddressIn.sin_port;
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
223 sa->sin_addr.s_addr = ii.iiAddress.AddressIn.sin_addr.s_addr;
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
224 tmp += sizeof(struct ifreq);
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
225
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
226 /* Make sure that we can fit in the original buffer */
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
227 if (tmp >= (ifc->ifc_buf + ifc->ifc_len + sizeof(struct ifreq))) {
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
228 break;
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
229 }
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
230 }
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
231 /* Replace the length with the actually used length */
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
232 ifc->ifc_len = ifc->ifc_len - (ifc->ifc_buf - tmp);
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
233 }
e1840eb860e7 [gaim-migrate @ 13588]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10601
diff changeset
234 }
3712
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
235 default:
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
236 errno = EINVAL;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
237 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
238 }/*end switch*/
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
239 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
240
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
241 /* arpa/inet.h */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
242 int wgaim_inet_aton(const char *name, struct in_addr *addr) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
243 if((addr->s_addr = inet_addr(name)) == INADDR_NONE)
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
244 return 0;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
245 else
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
246 return 1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
247 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
248
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
249 /* netdb.h */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
250 struct hostent* wgaim_gethostbyname(const char *name) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
251 struct hostent *hp;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
252
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
253 if((hp = gethostbyname(name)) == NULL) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
254 errno = WSAGetLastError();
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
255 return NULL;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
256 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
257 return hp;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
258 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
259
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
260 /* string.h */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
261 char* wgaim_strerror( int errornum ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
262 if( errornum > WSABASEERR ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
263 sprintf( errbuf, "Windows socket error #%d", errornum );
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
264 return errbuf;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
265 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
266 else
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
267 return strerror( errornum );
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
268 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
269
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
270 /* unistd.h */
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 /*
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
273 * 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
274 */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
275 int wgaim_read(int fd, void *buf, unsigned int size) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
276 int ret;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
277
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
278 if( wgaim_is_socket(fd) ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
279 if( (ret = recv(fd, buf, size, 0)) == SOCKET_ERROR ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
280 errno = WSAGetLastError();
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
281 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
282 }
11543
8be7f4c472cf [gaim-migrate @ 13798]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11431
diff changeset
283 #if 0
3712
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
284 else if( ret == 0 ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
285 /* connection has been gracefully closed */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
286 errno = WSAENOTCONN;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
287 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
288 }
11543
8be7f4c472cf [gaim-migrate @ 13798]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11431
diff changeset
289 #endif
3712
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
290 else {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
291 /* success reading socket */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
292 return ret;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
293 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
294 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
295 else {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
296 /* fd is not a socket handle.. pass it off to read */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
297 return read(fd, buf, size);
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
298 }
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 int wgaim_write(int fd, const void *buf, unsigned int size) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
302 int ret;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
303
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
304 if( wgaim_is_socket(fd) ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
305 if( (ret = send(fd, buf, size, 0)) == SOCKET_ERROR ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
306 errno = WSAGetLastError();
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
307 return -1;
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 else {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
310 /* success */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
311 return ret;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
312 }
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 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
315 else
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
316 return write(fd, buf, size);
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
317 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
318
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
319 int wgaim_close(int fd) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
320 int ret;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
321
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
322 if( wgaim_is_socket(fd) ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
323 if( (ret = closesocket(fd)) == SOCKET_ERROR ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
324 errno = WSAGetLastError();
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
325 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
326 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
327 else
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
328 return 0;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
329 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
330 else
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
331 return close(fd);
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
332 }
3777
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
333
8244
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
334 int wgaim_gethostname(char *name, size_t size) {
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
335 if(gethostname(name, size) == SOCKET_ERROR) {
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
336 errno = WSAGetLastError();
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
337 return -1;
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
338 }
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
339 return 0;
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
340 }
5e7ffea3f76a [gaim-migrate @ 8967]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
341
3777
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
342 /* sys/time.h */
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
343
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
344 int wgaim_gettimeofday(struct timeval *p, struct timezone *z) {
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
345 int res = 0;
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
346 struct _timeb timebuffer;
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
347
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
348 if (z != 0) {
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
349 _tzset();
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
350 z->tz_minuteswest = _timezone/60;
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
351 z->tz_dsttime = _daylight;
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
352 }
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
353
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
354 if (p != 0) {
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
355 _ftime(&timebuffer);
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
356 p->tv_sec = timebuffer.time; /* seconds since 1-1-1970 */
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
357 p->tv_usec = timebuffer.millitm*1000; /* microseconds */
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
358 }
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
359
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
360 return res;
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
361 }
4905
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 /* stdio.h */
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
364
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
365 int wgaim_rename (const char *oldname, const char *newname) {
10601
e46b51de549a [gaim-migrate @ 12028]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10589
diff changeset
366 struct stat oldstat, newstat;
4905
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
367
10601
e46b51de549a [gaim-migrate @ 12028]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10589
diff changeset
368 if(g_stat(oldname, &oldstat) == 0) {
4905
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
369 /* newname exists */
10601
e46b51de549a [gaim-migrate @ 12028]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10589
diff changeset
370 if(g_stat(newname, &newstat) == 0) {
4905
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
371 /* oldname is a dir */
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
372 if(_S_ISDIR(oldstat.st_mode)) {
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
373 if(!_S_ISDIR(newstat.st_mode)) {
10601
e46b51de549a [gaim-migrate @ 12028]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10589
diff changeset
374 return g_rename(oldname, newname);
4905
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
375 }
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
376 /* newname is a dir */
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
377 else {
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
378 /* This is not quite right.. If newname is empty and
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
379 is not a sub dir of oldname, newname should be
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
380 deleted and oldname should be renamed.
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
381 */
6425
26b739bc9f1a [gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
382 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "wgaim_rename does not behave here as it should\n");
10601
e46b51de549a [gaim-migrate @ 12028]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10589
diff changeset
383 return g_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 /* oldname is not a dir */
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
387 else {
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
388 /* newname is a dir */
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
389 if(_S_ISDIR(newstat.st_mode)) {
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
390 errno = EISDIR;
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
391 return -1;
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
392 }
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
393 /* newname is not a dir */
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
394 else {
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9611
diff changeset
395 g_remove(newname);
10601
e46b51de549a [gaim-migrate @ 12028]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10589
diff changeset
396 return g_rename(oldname, newname);
4905
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
397 }
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
398 }
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
399 }
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
400 /* newname doesn't exist */
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
401 else
10601
e46b51de549a [gaim-migrate @ 12028]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10589
diff changeset
402 return g_rename(oldname, newname);
4905
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
403 }
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
404 else {
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
405 /* oldname doesn't exist */
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
406 errno = ENOENT;
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
407 return -1;
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
408 }
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
409
86037d6bf80f [gaim-migrate @ 5239]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4193
diff changeset
410 }
5113
bac62d8d386f [gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
411
bac62d8d386f [gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
412 /* time.h */
bac62d8d386f [gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
413
bac62d8d386f [gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
414 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
415 struct tm* tmptm;
bac62d8d386f [gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
416
5474
0b355ec51083 [gaim-migrate @ 5868]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5113
diff changeset
417 if(!time)
5913
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5474
diff changeset
418 return NULL;
5113
bac62d8d386f [gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
419 tmptm = localtime(time);
bac62d8d386f [gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
420 if(resultp && tmptm)
bac62d8d386f [gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
421 return memcpy(resultp, tmptm, sizeof(struct tm));
bac62d8d386f [gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
422 else
bac62d8d386f [gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
423 return NULL;
bac62d8d386f [gaim-migrate @ 5476]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5084
diff changeset
424 }