comparison src/win32/libc_interface.c @ 3777:10ffafd1c91f

[gaim-migrate @ 3917] gettimeofday added committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Mon, 21 Oct 2002 18:32:24 +0000
parents ac6ca3890c53
children c297b9d4f67c
comparison
equal deleted inserted replaced
3776:21d296405cfd 3777:10ffafd1c91f
4 * Author: Herman Bloggs <hermanator12002@yahoo.com> 4 * Author: Herman Bloggs <hermanator12002@yahoo.com>
5 * Date: October 14, 2002 5 * Date: October 14, 2002
6 * Description: Commonly used libc routines. 6 * Description: Commonly used libc routines.
7 */ 7 */
8 #include <winsock.h> 8 #include <winsock.h>
9 #include <io.h>
9 #include <stdlib.h> 10 #include <stdlib.h>
11 #include <stdio.h>
10 #include <errno.h> 12 #include <errno.h>
13 #include <sys/timeb.h>
14 #include <time.h>
15 #include "libc_internal.h"
16
17 /*
18 * PROTOS
19 */
20 extern void debug_printf(char * fmt, ...);
21
22 /*
23 * LOCALS
24 */
11 25
12 static char errbuf[1024]; 26 static char errbuf[1024];
27
28 /*
29 * CODE
30 */
13 31
14 /* helpers */ 32 /* helpers */
15 static int wgaim_is_socket( int fd ) { 33 static int wgaim_is_socket( int fd ) {
16 int optval; 34 int optval;
17 unsigned int optlen = sizeof(int); 35 unsigned int optlen = sizeof(int);
67 return 0; 85 return 0;
68 } 86 }
69 87
70 /* fcntl.h */ 88 /* fcntl.h */
71 /* This is not a full implementation of fcntl. Update as needed.. */ 89 /* This is not a full implementation of fcntl. Update as needed.. */
72 #define O_NONBLOCK 1
73 #define F_SETFL 1
74 int wgaim_fcntl(int socket, int command, int val) { 90 int wgaim_fcntl(int socket, int command, int val) {
75 switch( command ) { 91 switch( command ) {
76 case F_SETFL: 92 case F_SETFL:
77 { 93 {
78 int ret=0; 94 int ret=0;
211 return 0; 227 return 0;
212 } 228 }
213 else 229 else
214 return close(fd); 230 return close(fd);
215 } 231 }
232
233 /* sys/time.h */
234
235 int wgaim_gettimeofday(struct timeval *p, struct timezone *z) {
236 int res = 0;
237 struct _timeb timebuffer;
238
239 if (z != 0) {
240 _tzset();
241 z->tz_minuteswest = _timezone/60;
242 z->tz_dsttime = _daylight;
243 }
244
245 if (p != 0) {
246 _ftime(&timebuffer);
247 p->tv_sec = timebuffer.time; /* seconds since 1-1-1970 */
248 p->tv_usec = timebuffer.millitm*1000; /* microseconds */
249 }
250
251 return res;
252 }