| 1 /* |
|
| 2 * gaim |
|
| 3 * |
|
| 4 * File: libc_interface.h |
|
| 5 * |
|
| 6 * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> |
|
| 7 * |
|
| 8 * This program is free software; you can redistribute it and/or modify |
|
| 9 * it under the terms of the GNU General Public License as published by |
|
| 10 * the Free Software Foundation; either version 2 of the License, or |
|
| 11 * (at your option) any later version. |
|
| 12 * |
|
| 13 * This program is distributed in the hope that it will be useful, |
|
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 * GNU General Public License for more details. |
|
| 17 * |
|
| 18 * You should have received a copy of the GNU General Public License |
|
| 19 * along with this program; if not, write to the Free Software |
|
| 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
| 21 * |
|
| 22 */ |
|
| 23 #ifndef _LIBC_INTERFACE_H_ |
|
| 24 #define _LIBC_INTERFACE_H_ |
|
| 25 #include <winsock2.h> |
|
| 26 #include <ws2tcpip.h> |
|
| 27 #include <io.h> |
|
| 28 #include <errno.h> |
|
| 29 #include "libc_internal.h" |
|
| 30 #include <glib.h> |
|
| 31 |
|
| 32 /* sys/socket.h */ |
|
| 33 int wgaim_socket(int namespace, int style, int protocol); |
|
| 34 #define socket( namespace, style, protocol ) \ |
|
| 35 wgaim_socket( namespace, style, protocol ) |
|
| 36 |
|
| 37 int wgaim_connect(int socket, struct sockaddr *addr, u_long length); |
|
| 38 #define connect( socket, addr, length ) \ |
|
| 39 wgaim_connect( socket, addr, length ) |
|
| 40 |
|
| 41 int wgaim_getsockopt(int socket, int level, int optname, void *optval, socklen_t *optlenptr); |
|
| 42 #define getsockopt( args... ) \ |
|
| 43 wgaim_getsockopt( args ) |
|
| 44 |
|
| 45 int wgaim_setsockopt(int socket, int level, int optname, const void *optval, socklen_t optlen); |
|
| 46 #define setsockopt( args... ) \ |
|
| 47 wgaim_setsockopt( args ) |
|
| 48 |
|
| 49 int wgaim_getsockname (int socket, struct sockaddr *addr, socklen_t *lenptr); |
|
| 50 #define getsockname( socket, addr, lenptr ) \ |
|
| 51 wgaim_getsockname( socket, addr, lenptr ) |
|
| 52 |
|
| 53 int wgaim_bind(int socket, struct sockaddr *addr, socklen_t length); |
|
| 54 #define bind( socket, addr, length ) \ |
|
| 55 wgaim_bind( socket, addr, length ) |
|
| 56 |
|
| 57 int wgaim_listen(int socket, unsigned int n); |
|
| 58 #define listen( socket, n ) \ |
|
| 59 wgaim_listen( socket, n ) |
|
| 60 |
|
| 61 int wgaim_sendto(int socket, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen); |
|
| 62 #define sendto(socket, buf, len, flags, to, tolen) \ |
|
| 63 wgaim_sendto(socket, buf, len, flags, to, tolen) |
|
| 64 |
|
| 65 /* sys/ioctl.h */ |
|
| 66 int wgaim_ioctl(int fd, int command, void* opt); |
|
| 67 #define ioctl( fd, command, val ) \ |
|
| 68 wgaim_ioctl( fd, command, val ) |
|
| 69 |
|
| 70 /* fcntl.h */ |
|
| 71 int wgaim_fcntl(int socket, int command, int val); |
|
| 72 #define fcntl( fd, command, val ) \ |
|
| 73 wgaim_fcntl( fd, command, val ) |
|
| 74 |
|
| 75 #if !GLIB_CHECK_VERSION(2,6,0) |
|
| 76 # define open( args... ) _open( args ) |
|
| 77 #endif |
|
| 78 |
|
| 79 /* arpa/inet.h */ |
|
| 80 int wgaim_inet_aton(const char *name, struct in_addr *addr); |
|
| 81 #define inet_aton( name, addr ) \ |
|
| 82 wgaim_inet_aton( name, addr ) |
|
| 83 |
|
| 84 /* netdb.h */ |
|
| 85 struct hostent* wgaim_gethostbyname(const char *name); |
|
| 86 #define gethostbyname( name ) \ |
|
| 87 wgaim_gethostbyname( name ) |
|
| 88 |
|
| 89 /* netinet/in.h */ |
|
| 90 #define ntohl( netlong ) \ |
|
| 91 (unsigned int)ntohl( netlong ) |
|
| 92 |
|
| 93 /* string.h */ |
|
| 94 char* wgaim_strerror( int errornum ); |
|
| 95 #define hstrerror( herror ) \ |
|
| 96 wgaim_strerror( errno ) |
|
| 97 #define strerror( errornum ) \ |
|
| 98 wgaim_strerror( errornum ) |
|
| 99 |
|
| 100 #define bzero( dest, size ) memset( dest, 0, size ) |
|
| 101 |
|
| 102 /* unistd.h */ |
|
| 103 int wgaim_read(int fd, void *buf, unsigned int size); |
|
| 104 #define read( fd, buf, buflen ) \ |
|
| 105 wgaim_read( fd, buf, buflen ) |
|
| 106 |
|
| 107 int wgaim_write(int fd, const void *buf, unsigned int size); |
|
| 108 #define write( socket, buf, buflen ) \ |
|
| 109 wgaim_write( socket, buf, buflen ) |
|
| 110 |
|
| 111 int wgaim_recv(int fd, void *buf, size_t len, int flags); |
|
| 112 #define recv(fd, buf, len, flags) \ |
|
| 113 wgaim_recv(fd, buf, len, flags) |
|
| 114 |
|
| 115 int wgaim_send(int fd, const void *buf, unsigned int size, int flags); |
|
| 116 #define send(socket, buf, buflen, flags) \ |
|
| 117 wgaim_send(socket, buf, buflen, flags) |
|
| 118 |
|
| 119 int wgaim_close(int fd); |
|
| 120 #define close( fd ) \ |
|
| 121 wgaim_close( fd ) |
|
| 122 |
|
| 123 #ifndef sleep |
|
| 124 #define sleep(x) Sleep((x)*1000) |
|
| 125 #endif |
|
| 126 |
|
| 127 int wgaim_gethostname(char *name, size_t size); |
|
| 128 #define gethostname( name, size ) \ |
|
| 129 wgaim_gethostname( name, size ) |
|
| 130 |
|
| 131 /* sys/time.h */ |
|
| 132 int wgaim_gettimeofday(struct timeval *p, struct timezone *z); |
|
| 133 #define gettimeofday( timeval, timezone ) \ |
|
| 134 wgaim_gettimeofday( timeval, timezone ) |
|
| 135 |
|
| 136 /* stdio.h */ |
|
| 137 #define snprintf _snprintf |
|
| 138 #define vsnprintf _vsnprintf |
|
| 139 |
|
| 140 int wgaim_rename(const char *oldname, const char *newname); |
|
| 141 #define rename( oldname, newname ) \ |
|
| 142 wgaim_rename( oldname, newname ) |
|
| 143 |
|
| 144 #if GLIB_CHECK_VERSION(2,6,0) |
|
| 145 #ifdef g_rename |
|
| 146 # undef g_rename |
|
| 147 #endif |
|
| 148 /* This is necessary because we want rename on win32 to be able to overwrite an existing file, it is done in internal.h if GLib < 2.6*/ |
|
| 149 #define g_rename(oldname, newname) \ |
|
| 150 wgaim_rename(oldname, newname) |
|
| 151 #endif |
|
| 152 |
|
| 153 |
|
| 154 /* sys/stat.h */ |
|
| 155 |
|
| 156 #if !GLIB_CHECK_VERSION(2,6,0) |
|
| 157 #define mkdir(a,b) _mkdir((a)) |
|
| 158 #endif |
|
| 159 #define fchmod(a,b) |
|
| 160 |
|
| 161 /* time.h */ |
|
| 162 struct tm *wgaim_localtime_r(const time_t *time, struct tm *resultp); |
|
| 163 #define localtime_r( time, resultp ) \ |
|
| 164 wgaim_localtime_r( time, resultp ) |
|
| 165 |
|
| 166 /* helper for gaim_utf8_strftime() by way of gaim_internal_strftime() in src/util.c */ |
|
| 167 const char *wgaim_get_timezone_abbreviation(const struct tm *tm); |
|
| 168 |
|
| 169 #endif /* _LIBC_INTERFACE_H_ */ |
|