| |
1 /* |
| |
2 * purple |
| |
3 * |
| |
4 * File: libc_internal.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_INTERNAL_ |
| |
24 #define _LIBC_INTERNAL_ |
| |
25 #include <glib.h> |
| |
26 |
| |
27 |
| |
28 /* sys/socket.h */ |
| |
29 int wpurple_socket(int namespace, int style, int protocol); |
| |
30 int wpurple_connect(int socket, struct sockaddr *addr, u_long length); |
| |
31 int wpurple_getsockopt(int socket, int level, int optname, void *optval, socklen_t *optlenptr); |
| |
32 int wpurple_setsockopt(int socket, int level, int optname, const void *optval, socklen_t optlen); |
| |
33 int wpurple_getsockname (int socket, struct sockaddr *addr, socklen_t *lenptr); |
| |
34 int wpurple_bind(int socket, struct sockaddr *addr, socklen_t length); |
| |
35 int wpurple_listen(int socket, unsigned int n); |
| |
36 int wpurple_sendto(int socket, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen); |
| |
37 int wpurple_recv(int fd, void *buf, size_t len, int flags); |
| |
38 int wpurple_send(int fd, const void *buf, unsigned int size, int flags); |
| |
39 |
| |
40 /* arpa/inet.h */ |
| |
41 int wpurple_inet_aton(const char *name, struct in_addr *addr); |
| |
42 const char * |
| |
43 wpurple_inet_ntop (int af, const void *src, char *dst, socklen_t cnt); |
| |
44 |
| |
45 /* netdb.h */ |
| |
46 struct hostent* wpurple_gethostbyname(const char *name); |
| |
47 |
| |
48 /* string.h */ |
| |
49 char* wpurple_strerror( int errornum ); |
| |
50 |
| |
51 /* fcntl.h */ |
| |
52 int wpurple_fcntl(int socket, int command, int val); |
| |
53 #define F_SETFL 1 |
| |
54 #define O_NONBLOCK 1 |
| |
55 |
| |
56 /* sys/ioctl.h */ |
| |
57 #define SIOCGIFCONF 0x8912 /* get iface list */ |
| |
58 int wpurple_ioctl(int fd, int command, void* opt); |
| |
59 |
| |
60 /* net/if.h */ |
| |
61 struct ifreq |
| |
62 { |
| |
63 union |
| |
64 { |
| |
65 char ifrn_name[6]; /* Interface name, e.g. "en0". */ |
| |
66 } ifr_ifrn; |
| |
67 |
| |
68 union |
| |
69 { |
| |
70 struct sockaddr ifru_addr; |
| |
71 #if 0 |
| |
72 struct sockaddr ifru_dstaddr; |
| |
73 struct sockaddr ifru_broadaddr; |
| |
74 struct sockaddr ifru_netmask; |
| |
75 struct sockaddr ifru_hwaddr; |
| |
76 short int ifru_flags; |
| |
77 int ifru_ivalue; |
| |
78 int ifru_mtu; |
| |
79 #endif |
| |
80 char *ifru_data; |
| |
81 } ifr_ifru; |
| |
82 }; |
| |
83 # define ifr_name ifr_ifrn.ifrn_name /* interface name */ |
| |
84 # define ifr_addr ifr_ifru.ifru_addr /* address */ |
| |
85 #if 0 |
| |
86 # define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ |
| |
87 # define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-p lnk */ |
| |
88 # define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ |
| |
89 # define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */ |
| |
90 # define ifr_flags ifr_ifru.ifru_flags /* flags */ |
| |
91 # define ifr_metric ifr_ifru.ifru_ivalue /* metric */ |
| |
92 # define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ |
| |
93 #endif |
| |
94 # define ifr_data ifr_ifru.ifru_data /* for use by interface */ |
| |
95 #if 0 |
| |
96 # define ifr_ifindex ifr_ifru.ifru_ivalue /* interface index */ |
| |
97 # define ifr_bandwidth ifr_ifru.ifru_ivalue /* link bandwidth */ |
| |
98 # define ifr_qlen ifr_ifru.ifru_ivalue /* queue length */ |
| |
99 #endif |
| |
100 |
| |
101 |
| |
102 struct ifconf |
| |
103 { |
| |
104 int ifc_len; /* Size of buffer. */ |
| |
105 union |
| |
106 { |
| |
107 char *ifcu_buf; |
| |
108 struct ifreq *ifcu_req; |
| |
109 } ifc_ifcu; |
| |
110 }; |
| |
111 # define ifc_buf ifc_ifcu.ifcu_buf /* Buffer address. */ |
| |
112 # define ifc_req ifc_ifcu.ifcu_req /* Array of structures. */ |
| |
113 |
| |
114 /* sys/time.h */ |
| |
115 struct timezone { |
| |
116 int tz_minuteswest; |
| |
117 int tz_dsttime; |
| |
118 }; |
| |
119 int wpurple_gettimeofday(struct timeval *p, struct timezone *z); |
| |
120 |
| |
121 /* time.h */ |
| |
122 struct tm *wpurple_localtime_r(const time_t *time, struct tm *resultp); |
| |
123 |
| |
124 |
| |
125 /* unistd.h */ |
| |
126 int wpurple_read(int fd, void *buf, unsigned int size); |
| |
127 int wpurple_write(int fd, const void *buf, unsigned int size); |
| |
128 int wpurple_close(int fd); |
| |
129 int wpurple_gethostname(char *name, size_t size); |
| |
130 |
| |
131 |
| |
132 #if !GLIB_CHECK_VERSION(2,8,0) |
| |
133 int wpurple_g_access(const gchar *filename, int mode); |
| |
134 #endif |
| |
135 |
| |
136 /* stdio.h */ |
| |
137 int wpurple_rename(const char *oldname, const char *newname); |
| |
138 |
| |
139 #endif /* _LIBC_INTERNAL_ */ |