]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/unix/gsockunx.h
fixed typo
[wxWidgets.git] / include / wx / unix / gsockunx.h
... / ...
CommitLineData
1/* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
3 * Name: gsockunx.h
4 * Purpose: GSocket Unix header
5 * CVSID: $Id$
6 * -------------------------------------------------------------------------
7 */
8
9#ifndef __GSOCK_UNX_H
10#define __GSOCK_UNX_H
11
12#ifndef __GSOCKET_STANDALONE__
13#include "wx/setup.h"
14#endif
15
16#if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
17
18#ifndef __GSOCKET_STANDALONE__
19#include "wx/gsocket.h"
20#else
21#include "gsocket.h"
22#endif
23
24#ifndef TRUE
25#define TRUE 1
26#endif
27
28#ifndef FALSE
29#define FALSE 0
30#endif
31
32#ifdef wxUSE_GSOCKET_CPLUSPLUS
33class GSocketGUIFunctionsTableConcrete: public GSocketGUIFunctionsTable
34{
35public:
36 virtual bool OnInit();
37 virtual void OnExit();
38 virtual bool CanUseEventLoop();
39 virtual bool Init_Socket(GSocket *socket);
40 virtual void Destroy_Socket(GSocket *socket);
41 virtual void Install_Callback(GSocket *socket, GSocketEvent event);
42 virtual void Uninstall_Callback(GSocket *socket, GSocketEvent event);
43 virtual void Enable_Events(GSocket *socket);
44 virtual void Disable_Events(GSocket *socket);
45};
46#endif /* def wxUSE_GSOCKET_CPLUSPLUS */
47
48#ifdef wxUSE_GSOCKET_CPLUSPLUS
49class GSocket
50{
51public:
52 GSocket();
53 virtual ~GSocket();
54 bool IsOk() { return m_ok; }
55 void Close();
56 void Shutdown();
57 GSocketError SetLocal(GAddress *address);
58 GSocketError SetPeer(GAddress *address);
59 GAddress *GetLocal();
60 GAddress *GetPeer();
61 GSocketError SetServer();
62 GSocket *WaitConnection();
63 int SetReusable();
64 GSocketError Connect(GSocketStream stream);
65 GSocketError SetNonOriented();
66 int Read(char *buffer, int size);
67 int Write(const char *buffer, int size);
68 GSocketEventFlags Select(GSocketEventFlags flags);
69 void SetNonBlocking(int non_block);
70 void SetTimeout(unsigned long millisec);
71 GSocketError WXDLLIMPEXP_NET GetError();
72 void SetCallback(GSocketEventFlags flags,
73 GSocketCallback callback, char *cdata);
74 void UnsetCallback(GSocketEventFlags flags);
75 GSocketError GetSockOpt(int level, int optname, void *optval, int *optlen);
76 GSocketError SetSockOpt(int level, int optname,
77 const void *optval, int optlen);
78 /* API compatibility functions */
79 static void _GSocket_Detected_Read(GSocket *socket);
80 static void _GSocket_Detected_Write(GSocket *socket);
81 virtual void Detected_Read();
82 virtual void Detected_Write();
83protected:
84 void Enable(GSocketEvent event);
85 void Disable(GSocketEvent event);
86 GSocketError Input_Timeout();
87 GSocketError Output_Timeout();
88 int Recv_Stream(char *buffer, int size);
89 int Recv_Dgram(char *buffer, int size);
90 int Send_Stream(const char *buffer, int size);
91 int Send_Dgram(const char *buffer, int size);
92 bool m_ok;
93public:
94 /* DFE: We can't protect these data member until the GUI code is updated */
95 /* protected: */
96#else /* def wxUSE_GSOCKET_CPLUSPLUS */
97
98#ifdef __cplusplus
99extern "C" {
100#endif /* __cplusplus */
101/* Definition of GSocket */
102struct _GSocket
103{
104#endif /* def wxUSE_GSOCKET_CPLUSPLUS */
105 int m_fd;
106 GAddress *m_local;
107 GAddress *m_peer;
108 GSocketError m_error;
109
110 int m_non_blocking;
111 int m_server;
112 int m_stream;
113 int m_establishing;
114 int m_reusable;
115 unsigned long m_timeout;
116
117 /* Callbacks */
118 GSocketEventFlags m_detected;
119 GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
120 char *m_data[GSOCK_MAX_EVENT];
121
122 char *m_gui_dependent;
123
124#ifndef wxUSE_GSOCKET_CPLUSPLUS
125 /* Function pointers */
126 struct GSocketBaseFunctionsTable *m_functions;
127#endif /* ndef wxUSE_GSOCKET_CPLUSPLUS */
128};
129#ifndef wxUSE_GSOCKET_CPLUSPLUS
130#ifdef __cplusplus
131}
132#endif /* __cplusplus */
133#endif /* ndef wxUSE_GSOCKET_CPLUSPLUS */
134
135#ifdef __cplusplus
136extern "C" {
137#endif /* __cplusplus */
138/* Definition of GAddress */
139struct _GAddress
140{
141 struct sockaddr *m_addr;
142 size_t m_len;
143
144 GAddressType m_family;
145 int m_realfamily;
146
147 GSocketError m_error;
148};
149#ifdef __cplusplus
150}
151#endif /* __cplusplus */
152
153/* Compatibility methods to support old C API (from gsocket.h) */
154#ifdef wxUSE_GSOCKET_CPLUSPLUS
155inline void GSocket_Shutdown(GSocket *socket)
156{ socket->Shutdown(); }
157inline GSocketError GSocket_SetLocal(GSocket *socket, GAddress *address)
158{ return socket->SetLocal(address); }
159inline GSocketError GSocket_SetPeer(GSocket *socket, GAddress *address)
160{ return socket->SetPeer(address); }
161inline GAddress *GSocket_GetLocal(GSocket *socket)
162{ return socket->GetLocal(); }
163inline GAddress *GSocket_GetPeer(GSocket *socket)
164{ return socket->GetPeer(); }
165inline GSocketError GSocket_SetServer(GSocket *socket)
166{ return socket->SetServer(); }
167inline GSocket *GSocket_WaitConnection(GSocket *socket)
168{ return socket->WaitConnection(); }
169inline int GSocket_SetReusable(GSocket *socket)
170{ return socket->SetReusable(); }
171inline GSocketError GSocket_Connect(GSocket *socket, GSocketStream stream)
172{ return socket->Connect(stream); }
173inline GSocketError GSocket_SetNonOriented(GSocket *socket)
174{ return socket->SetNonOriented(); }
175inline int GSocket_Read(GSocket *socket, char *buffer, int size)
176{ return socket->Read(buffer,size); }
177inline int GSocket_Write(GSocket *socket, const char *buffer, int size)
178{ return socket->Write(buffer,size); }
179inline GSocketEventFlags GSocket_Select(GSocket *socket, GSocketEventFlags flags)
180{ return socket->Select(flags); }
181inline void GSocket_SetNonBlocking(GSocket *socket, int non_block)
182{ socket->SetNonBlocking(non_block); }
183inline void GSocket_SetTimeout(GSocket *socket, unsigned long millisec)
184{ socket->SetTimeout(millisec); }
185inline GSocketError GSocket_GetError(GSocket *socket)
186{ return socket->GetError(); }
187inline void GSocket_SetCallback(GSocket *socket, GSocketEventFlags flags,
188 GSocketCallback fallback, char *cdata)
189{ socket->SetCallback(flags,fallback,cdata); }
190inline void GSocket_UnsetCallback(GSocket *socket, GSocketEventFlags flags)
191{ socket->UnsetCallback(flags); }
192inline GSocketError GSocket_GetSockOpt(GSocket *socket, int level, int optname,
193 void *optval, int *optlen)
194{ return socket->GetSockOpt(level,optname,optval,optlen); }
195inline GSocketError GSocket_SetSockOpt(GSocket *socket, int level, int optname,
196 const void *optval, int optlen)
197{ return socket->SetSockOpt(level,optname,optval,optlen); }
198inline void GSocket_destroy(GSocket *socket)
199{ delete socket; }
200
201#endif /* def wxUSE_GSOCKET_CPLUSPLUS */
202
203#ifdef __cplusplus
204extern "C" {
205#endif /* __cplusplus */
206
207/* Input / Output */
208
209GSocketError _GSocket_Input_Timeout(GSocket *socket);
210GSocketError _GSocket_Output_Timeout(GSocket *socket);
211int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size);
212int _GSocket_Recv_Dgram(GSocket *socket, char *buffer, int size);
213int _GSocket_Send_Stream(GSocket *socket, const char *buffer, int size);
214int _GSocket_Send_Dgram(GSocket *socket, const char *buffer, int size);
215
216/* Callbacks */
217
218int _GSocket_GUI_Init(void);
219void _GSocket_GUI_Cleanup(void);
220
221int _GSocket_GUI_Init_Socket(GSocket *socket);
222void _GSocket_GUI_Destroy_Socket(GSocket *socket);
223
224void _GSocket_Enable_Events(GSocket *socket);
225void _GSocket_Disable_Events(GSocket *socket);
226void _GSocket_Install_Callback(GSocket *socket, GSocketEvent event);
227void _GSocket_Uninstall_Callback(GSocket *socket, GSocketEvent event);
228
229void _GSocket_Enable(GSocket *socket, GSocketEvent event);
230void _GSocket_Disable(GSocket *socket, GSocketEvent event);
231
232#ifndef wxUSE_GSOCKET_CPLUSPLUS
233void _GSocket_Detected_Read(GSocket *socket);
234void _GSocket_Detected_Write(GSocket *socket);
235#endif /* ndef wxUSE_GSOCKET_CPLUSPLUS */
236
237/* GAddress */
238
239GSocketError _GAddress_translate_from(GAddress *address,
240 struct sockaddr *addr, int len);
241GSocketError _GAddress_translate_to (GAddress *address,
242 struct sockaddr **addr, int *len);
243GSocketError _GAddress_Init_INET(GAddress *address);
244GSocketError _GAddress_Init_UNIX(GAddress *address);
245
246
247#ifdef __cplusplus
248}
249#endif /* __cplusplus */
250
251#endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
252
253#endif /* __GSOCK_UNX_H */