File: SocketBase.xs

package info (click to toggle)
libwx-perl 1%3A0.9932-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,300 kB
  • sloc: cpp: 11,064; perl: 8,603; ansic: 711; makefile: 53
file content (238 lines) | stat: -rw-r--r-- 5,061 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#############################################################################
## Name:        ext/socket/XS/SocketBase.xs
## Purpose:     XS for Wx::SocketBase
## Author:      Graciliano M. P.
## Created:     27/02/2003
## RCS-ID:      $Id: SocketBase.xs 2057 2007-06-18 23:03:00Z mbarbon $
## Copyright:   (c) 2003-2004, 2006-2007 Graciliano M. P.
## Licence:     This program is free software; you can redistribute it and/or
##              modify it under the same terms as Perl itself
#############################################################################


MODULE=Wx PACKAGE=Wx::SocketBase

#if 0

wxSocketBase*
wxSocketBase::new()
  CODE:
    RETVAL = new wxPlSocketBase( CLASS ) ;
  OUTPUT: RETVAL

#endif

void
wxSocketBase::Destroy()

bool
wxSocketBase::Ok()

bool
wxSocketBase::IsConnected()

bool
wxSocketBase::IsDisconnected()

bool
wxSocketBase::IsData()

long
wxSocketBase::LastCount()

void
wxSocketBase::Notify( notify )
    bool notify
    
void 
wxSocketBase::SetTimeout( seconds )
    int seconds
    
bool
wxSocketBase::Wait( seconds = -1 , millisecond = 0 )
    long seconds
    long millisecond

bool
wxSocketBase::WaitForRead( seconds = -1 , millisecond = 0 )
    long seconds
    long millisecond
    
bool
wxSocketBase::WaitForWrite( seconds = -1 , millisecond = 0 )
    long seconds
    long millisecond
    
long
wxSocketBase::Read( buf , size , leng = 0 )
    SV* buf
    size_t size
    size_t leng
  CODE:
    // Upgrade the SV to scalar if needed. If the scalar is undef
    // can't use SvGROW.
    SvUPGRADE(buf , SVt_PV) ;
    // Tell that the scalar is string only (not integer, double, utf8...):
    SvPOK_only(buf) ;
    
    // Grow the scalar to receive the data and return a char* point:
    char* buffer = SvGROW( buf , leng + size + 2 ) ;

    // To read at the offset the user specified (works even if offset = 0):
    if ( leng > 0 ) buffer += leng ;

    THIS->Read( buffer , size ) ;
    int nread = THIS->LastCount() ;

    // Null-terminate the buffer, not necessary, but does not hurt:
    buffer[nread] = 0 ;
    // Tell Perl how long the string is:
    SvCUR_set( buf , leng + nread ) ;
    // Undef on read error:
    if( THIS->Error() ) XSRETURN_UNDEF ;
    // Return the amount of data read, like Perl read().
    RETVAL = nread ;
  OUTPUT: RETVAL

void
wxSocketBase::Close()

void
wxSocketBase::Discard()

bool
wxSocketBase::Error()

long
wxSocketBase::GetFlags()


void
wxSocketBase::GetLocal()
  PPCODE:
    wxIPV4address addr ;
    THIS->GetLocal( addr ) ;
    XPUSHs( sv_2mortal( newSVpv( addr.Hostname().mb_str(), 0 ) ) );
    XPUSHs( sv_2mortal( newSViv( addr.Service() ) ) );


void
wxSocketBase::GetPeer()
  PPCODE:
    wxIPV4address addr ;
    THIS->GetPeer( addr ) ;
    XPUSHs( sv_2mortal( newSVpv( addr.Hostname().mb_str(), 0 ) ) );
    XPUSHs( sv_2mortal( newSViv( addr.Service() ) ) );


void
wxSocketBase::InterruptWait()

long
wxSocketBase::LastError()

long
wxSocketBase::Peek(buf , size , leng = 0 )
    SV* buf
    size_t size
    size_t leng
  CODE:
    SvUPGRADE(buf , SVt_PV) ;
    SvPOK_only(buf) ;
    char* buffer = SvGROW( buf , leng + size + 2 ) ;
    if ( leng > 0 ) { buffer += leng ;}

    THIS->Peek( buffer , size ) ;
    int nread = THIS->LastCount() ;

    buffer[nread] = 0 ;
    SvCUR_set( buf , leng + nread ) ;
    if( THIS->Error() ) XSRETURN_UNDEF ;
    RETVAL = nread ;
  OUTPUT: RETVAL


long
wxSocketBase::ReadMsg(buf , size , leng = 0 )
    SV* buf
    size_t size
    size_t leng
  CODE:
    SvUPGRADE(buf , SVt_PV) ;
    SvPOK_only(buf) ;
    char* buffer = SvGROW( buf , leng + size + 2 ) ;
    if ( leng > 0 ) { buffer += leng ;}

    THIS->ReadMsg( buffer , size ) ;
    int nread = THIS->LastCount() ;

    buffer[nread] = 0 ;
    SvCUR_set( buf , leng + nread ) ;
    if( THIS->Error() ) XSRETURN_UNDEF ;
    RETVAL = nread ;
  OUTPUT: RETVAL


void
wxSocketBase::RestoreState()

void
wxSocketBase::SaveState()

void
wxSocketBase::SetFlags(flags)
    long flags

void
wxSocketBase::SetNotify(flags)
    long flags


long
wxSocketBase::Unread(buf , size = 0)
    SV* buf
    long size
  CODE:
    // Upgrade the SV to scalar if needed. If the scalar is undef 
    // can't use SvGROW.
    SvUPGRADE(buf , SVt_PV) ;
    
    if ( size == 0 ) { size = SvCUR(buf) ;}
    THIS->Unread( SvPV_nolen(buf) , size ) ;
    RETVAL = THIS->LastCount() ;
  OUTPUT: RETVAL

bool
wxSocketBase::WaitForLost( seconds = -1 , millisecond = 0 )
    long seconds
    long millisecond

long
wxSocketBase::Write(buf , size = 0)
    SV* buf
    long size
  CODE:
    if ( size == 0 ) { size = SvCUR(buf) ;}
    THIS->Write( SvPV_nolen(buf) , size ) ;
    RETVAL = THIS->LastCount() ;
  OUTPUT: RETVAL

long
wxSocketBase::WriteMsg(buf , size = 0)
    SV* buf
    long size
  CODE:
    if ( size == 0 ) { size = SvCUR(buf) ;}
    THIS->WriteMsg( SvPV_nolen(buf) , size ) ;
    RETVAL = THIS->LastCount() ;
  OUTPUT: RETVAL


void
wxSocketBase::SetEventHandler( evthnd , id = wxID_ANY )
    wxEvtHandler* evthnd
    int id
  CODE:
    THIS->SetEventHandler( *evthnd , id );