annotate src/win32/libc_interface.c @ 4866:703e02e52262

[gaim-migrate @ 5196] Added new typed and typing images to replace the gear. Missing stock icons now result in critical errors being shown. Restored the away button icon. Yay! You may now serve me cheese. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sat, 22 Mar 2003 22:24:33 +0000
parents c297b9d4f67c
children 86037d6bf80f
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 /*
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
2 * libc_interface.c
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
3 *
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
4 * Author: Herman Bloggs <hermanator12002@yahoo.com>
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
5 * Date: October 14, 2002
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
6 * Description: Commonly used libc routines.
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
7 */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
8 #include <winsock.h>
3777
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
9 #include <io.h>
3712
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
10 #include <stdlib.h>
3777
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
11 #include <stdio.h>
3712
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
12 #include <errno.h>
3777
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
13 #include <sys/timeb.h>
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
14 #include <time.h>
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
15 #include "libc_internal.h"
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
16
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
17 /*
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
18 * PROTOS
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
19 */
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
20 extern void debug_printf(char * fmt, ...);
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
21
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
22 /*
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
23 * LOCALS
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
24 */
3712
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
25
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
26 static char errbuf[1024];
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
27
3777
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
28 /*
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
29 * CODE
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
30 */
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
31
3712
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
32 /* helpers */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
33 static int wgaim_is_socket( int fd ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
34 int optval;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
35 unsigned int optlen = sizeof(int);
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
36
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
37 if( (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void*)&optval, &optlen)) == SOCKET_ERROR ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
38 int error = WSAGetLastError();
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
39 if( error == WSAENOTSOCK )
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
40 return FALSE;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
41 else {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
42 debug_printf("wgaim_read: getsockopt returned error: %d\n", error);
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
43 return FALSE;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
44 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
45 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
46 return TRUE;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
47 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
48
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
49 /* socket.h */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
50 int wgaim_socket (int namespace, int style, int protocol) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
51 int ret;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
52
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
53 ret = socket( namespace, style, protocol );
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
54
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
55 if( ret == INVALID_SOCKET ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
56 errno = WSAGetLastError();
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
57 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
58 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
59 return ret;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
60 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
61
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
62 int wgaim_connect(int socket, struct sockaddr *addr, u_long length) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
63 int ret;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
64
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
65 ret = connect( socket, addr, length );
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
66
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
67 if( ret == SOCKET_ERROR ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
68 errno = WSAGetLastError();
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
69 if( errno == WSAEWOULDBLOCK )
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
70 errno = WSAEINPROGRESS;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
71 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
72 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
73 return 0;
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
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
76 int wgaim_getsockopt(int socket, int level, int optname, void *optval, unsigned int *optlenptr) {
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 = getsockopt( socket, level, optname, optval, optlenptr );
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
80 if( ret == SOCKET_ERROR ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
81 errno = WSAGetLastError();
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
82 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
83 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
84
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
85 return 0;
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 /* fcntl.h */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
89 /* This is not a full implementation of fcntl. Update as needed.. */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
90 int wgaim_fcntl(int socket, int command, int val) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
91 switch( command ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
92 case F_SETFL:
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
93 {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
94 int ret=0;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
95
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
96 switch( val ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
97 case O_NONBLOCK:
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 u_long imode=1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
100 ret = ioctlsocket(socket, FIONBIO, &imode);
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
101 break;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
102 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
103 case 0:
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
104 {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
105 u_long imode=0;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
106 ret = ioctlsocket(socket, FIONBIO, &imode);
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
107 break;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
108 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
109 default:
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
110 errno = EINVAL;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
111 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
112 }/*end switch*/
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
113 if( ret == SOCKET_ERROR ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
114 errno = WSAGetLastError();
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
115 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
116 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
117 return 0;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
118 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
119 default:
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
120 debug_printf("wgaim_fcntl: Unsupported command\n");
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
121 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
122 }/*end switch*/
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
123 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
124
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
125 /* sys/ioctl.h */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
126 int wgaim_ioctl(int fd, int command, void* val) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
127 switch( command ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
128 case FIONBIO:
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
129 {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
130 if (ioctlsocket(fd, FIONBIO, (unsigned long *)val) == SOCKET_ERROR) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
131 errno = WSAGetLastError();
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
132 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
133 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
134 return 0;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
135 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
136 default:
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
137 errno = EINVAL;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
138 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
139 }/*end switch*/
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
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
142 /* arpa/inet.h */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
143 int wgaim_inet_aton(const char *name, struct in_addr *addr) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
144 if((addr->s_addr = inet_addr(name)) == INADDR_NONE)
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
145 return 0;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
146 else
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
147 return 1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
148 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
149
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
150 /* netdb.h */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
151 struct hostent* wgaim_gethostbyname(const char *name) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
152 struct hostent *hp;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
153
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
154 if((hp = gethostbyname(name)) == NULL) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
155 errno = WSAGetLastError();
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
156 return NULL;
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 return hp;
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
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
161 /* string.h */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
162 char* wgaim_strerror( int errornum ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
163 if( errornum > WSABASEERR ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
164 sprintf( errbuf, "Windows socket error #%d", errornum );
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
165 return errbuf;
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 else
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
168 return strerror( errornum );
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
169 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
170
4193
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
171 /* From glibc 2.2.5 */
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
172 char* wgaim_strsep(char **stringp, const char *delim) {
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
173 char *begin, *end;
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
174
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
175 begin = *stringp;
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
176 if (begin == NULL)
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
177 return NULL;
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
178
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
179 /* A frequent case is when the delimiter string contains only one
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
180 character. Here we don't need to call the expensive `strpbrk'
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
181 function and instead work using `strchr'. */
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
182 if (delim[0] == '\0' || delim[1] == '\0') {
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
183 char ch = delim[0];
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
184
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
185 if (ch == '\0')
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
186 end = NULL;
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
187 else {
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
188 if (*begin == ch)
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
189 end = begin;
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
190 else if (*begin == '\0')
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
191 end = NULL;
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
192 else
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
193 end = strchr (begin + 1, ch);
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
194 }
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
195 }
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
196 else
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
197 /* Find the end of the token. */
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
198 end = strpbrk (begin, delim);
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
199
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
200 if (end) {
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
201 /* Terminate the token and set *STRINGP past NUL character. */
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
202 *end++ = '\0';
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
203 *stringp = end;
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
204 }
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
205 else
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
206 /* No more delimiters; this is the last token. */
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
207 *stringp = NULL;
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
208
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
209 return begin;
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
210 }
c297b9d4f67c [gaim-migrate @ 4424]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3777
diff changeset
211
3712
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
212 /* unistd.h */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
213
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
214 /*
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
215 * 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
216 */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
217 int wgaim_read(int fd, void *buf, unsigned int size) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
218 int ret;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
219
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
220 if( wgaim_is_socket(fd) ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
221 if( (ret = recv(fd, buf, size, 0)) == SOCKET_ERROR ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
222 errno = WSAGetLastError();
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
223 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
224 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
225 else if( ret == 0 ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
226 /* connection has been gracefully closed */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
227 errno = WSAENOTCONN;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
228 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
229 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
230 else {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
231 /* success reading socket */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
232 return ret;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
233 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
234 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
235 else {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
236 /* fd is not a socket handle.. pass it off to read */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
237 return read(fd, buf, size);
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
238 }
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 int wgaim_write(int fd, const void *buf, unsigned int size) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
242 int ret;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
243
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
244 if( wgaim_is_socket(fd) ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
245 if( (ret = send(fd, buf, size, 0)) == SOCKET_ERROR ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
246 errno = WSAGetLastError();
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
247 return -1;
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 else {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
250 /* success */
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
251 return ret;
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
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
254 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
255 else
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
256 return write(fd, buf, size);
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
257 }
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 int wgaim_close(int fd) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
260 int ret;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
261
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
262 if( wgaim_is_socket(fd) ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
263 if( (ret = closesocket(fd)) == SOCKET_ERROR ) {
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
264 errno = WSAGetLastError();
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
265 return -1;
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
266 }
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
267 else
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
268 return 0;
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 else
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
271 return close(fd);
ac6ca3890c53 [gaim-migrate @ 3845]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
272 }
3777
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
273
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
274 /* sys/time.h */
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
275
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
276 int wgaim_gettimeofday(struct timeval *p, struct timezone *z) {
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
277 int res = 0;
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
278 struct _timeb timebuffer;
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
279
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
280 if (z != 0) {
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
281 _tzset();
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
282 z->tz_minuteswest = _timezone/60;
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
283 z->tz_dsttime = _daylight;
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
284 }
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
285
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
286 if (p != 0) {
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
287 _ftime(&timebuffer);
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
288 p->tv_sec = timebuffer.time; /* seconds since 1-1-1970 */
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
289 p->tv_usec = timebuffer.millitm*1000; /* microseconds */
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
290 }
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
291
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
292 return res;
10ffafd1c91f [gaim-migrate @ 3917]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3712
diff changeset
293 }