]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/gsockmac.h
fix ifdef - its libpng not pnglib :)
[wxWidgets.git] / include / wx / mac / carbon / gsockmac.h
1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
3 * Name: gsockunx.h
4 * Purpose: GSocket Macintosh 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 #include <MacHeaders.c>
25 #define OTUNIXERRORS 1
26 #include <OpenTransport.h>
27 #include <OpenTransportProviders.h>
28 #include <OpenTptInternet.h>
29
30 /* Definition of GSocket */
31 class GSocket
32 {
33 public:
34 GSocket();
35 ~GSocket();
36 bool IsOk() { return m_ok; }
37
38 void Shutdown();
39 GSocketError SetLocal(GAddress *address);
40 GSocketError SetPeer(GAddress *address);
41 GAddress *GetLocal();
42 GAddress *GetPeer();
43 GSocketError SetServer();
44 GSocket *WaitConnection();
45 bool SetReusable() { return false; }
46 GSocketError SetNonOriented();
47 GSocketError Connect(GSocketStream stream);
48 int Read(char *buffer, int size);
49 int Write(const char *buffer, int size);
50 GSocketEventFlags Select(GSocketEventFlags flags);
51 void SetNonBlocking(bool non_block);
52 void SetTimeout(unsigned long millisec);
53 GSocketError WXDLLIMPEXP_NET GetError();
54 void SetCallback(GSocketEventFlags flags,
55 GSocketCallback callback, char *cdata);
56 void UnsetCallback(GSocketEventFlags flags);
57 GSocketError GetSockOpt(int level, int optname, void *optval, int *optlen)
58 { return GSOCK_INVOP; }
59 GSocketError SetSockOpt(int level, int optname,
60 const void *optval, int optlen)
61 { return GSOCK_INVOP; }
62
63 protected:
64 bool m_ok;
65
66 /* Input / Output */
67 GSocketError Input_Timeout();
68 GSocketError Output_Timeout();
69 int Recv_Stream(char *buffer, int size);
70 int Recv_Dgram(char *buffer, int size);
71 int Send_Stream(const char *buffer, int size);
72 int Send_Dgram(const char *buffer, int size);
73
74 /* Callbacks */
75 void Enable_Events();
76 void Disable_Events();
77
78 // TODO: Make these protected
79 public:
80 wxMacNotifierTableRef m_mac_events ;
81 EndpointRef m_endpoint;
82 GAddress *m_local;
83 GAddress *m_peer;
84 GSocketError m_error;
85
86 bool m_non_blocking;
87 bool m_server;
88 bool m_stream;
89 bool m_oriented;
90 unsigned long m_timeout;
91
92 /* Callbacks */
93 GSocketEventFlags m_detected;
94 GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
95 char *m_data[GSOCK_MAX_EVENT];
96 bool m_takesEvents ;
97 };
98
99
100 #ifdef __cplusplus
101 extern "C" {
102 #endif /* __cplusplus */
103
104 /* Definition of GAddress */
105
106 struct _GAddress
107 {
108 UInt32 m_host ;
109 UInt16 m_port ;
110 GAddressType m_family;
111 GSocketError m_error;
112 };
113
114 /* Callbacks */
115
116 void _GSocket_Internal_Proc(unsigned long e , void* data ) ;
117
118 /* GAddress */
119
120 GSocketError _GAddress_translate_from(GAddress *address,
121 InetAddress *addr );
122 GSocketError _GAddress_translate_to(GAddress *address,
123 InetAddress *addr);
124
125 GSocketError _GAddress_Init_INET(GAddress *address);
126
127 #ifdef __cplusplus
128 }
129 #endif /* __cplusplus */
130
131 #endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
132
133 #endif /* __GSOCK_UNX_H */