WSABUF struct

db4
Doug Coleman 2009-08-29 19:25:18 -05:00
parent 135d56fcd2
commit a81c78e485
2 changed files with 12 additions and 13 deletions

View File

@ -2,7 +2,8 @@ USING: alien alien.accessors alien.c-types byte-arrays
continuations destructors io.ports io.timeouts io.sockets continuations destructors io.ports io.timeouts io.sockets
io namespaces io.streams.duplex io.backend.windows io namespaces io.streams.duplex io.backend.windows
io.sockets.windows io.backend.windows.nt windows.winsock kernel io.sockets.windows io.backend.windows.nt windows.winsock kernel
libc math sequences threads system combinators accessors ; libc math sequences threads system combinators accessors
classes.struct ;
IN: io.sockets.windows.nt IN: io.sockets.windows.nt
: malloc-int ( object -- object ) : malloc-int ( object -- object )
@ -127,9 +128,9 @@ TUPLE: WSARecvFrom-args port
lpFlags lpFrom lpFromLen lpOverlapped lpCompletionRoutine ; lpFlags lpFrom lpFromLen lpOverlapped lpCompletionRoutine ;
: make-receive-buffer ( -- WSABUF ) : make-receive-buffer ( -- WSABUF )
"WSABUF" malloc-object &free WSABUF malloc-struct &free
default-buffer-size get over set-WSABUF-len default-buffer-size get
default-buffer-size get malloc &free over set-WSABUF-buf ; inline [ >>len ] [ malloc &free >>buf ] bi ; inline
: <WSARecvFrom-args> ( datagram -- WSARecvFrom ) : <WSARecvFrom-args> ( datagram -- WSARecvFrom )
WSARecvFrom-args new WSARecvFrom-args new
@ -158,7 +159,7 @@ TUPLE: WSARecvFrom-args port
} cleave WSARecvFrom socket-error* ; inline } cleave WSARecvFrom socket-error* ; inline
: parse-WSARecvFrom ( n WSARecvFrom -- packet sockaddr ) : parse-WSARecvFrom ( n WSARecvFrom -- packet sockaddr )
[ lpBuffers>> WSABUF-buf swap memory>byte-array ] [ lpBuffers>> buf>> swap memory>byte-array ]
[ [ lpFrom>> ] [ lpFromLen>> *int ] bi memory>byte-array ] bi ; inline [ [ lpFrom>> ] [ lpFromLen>> *int ] bi memory>byte-array ] bi ; inline
M: winnt (receive) ( datagram -- packet addrspec ) M: winnt (receive) ( datagram -- packet addrspec )
@ -175,11 +176,9 @@ TUPLE: WSASendTo-args port
dwFlags lpTo iToLen lpOverlapped lpCompletionRoutine ; dwFlags lpTo iToLen lpOverlapped lpCompletionRoutine ;
: make-send-buffer ( packet -- WSABUF ) : make-send-buffer ( packet -- WSABUF )
"WSABUF" malloc-object &free [ WSABUF malloc-struct &free ] dip
[ [ malloc-byte-array &free ] dip set-WSABUF-buf ] [ malloc-byte-array &free >>buf ]
[ [ length ] dip set-WSABUF-len ] [ length >>len ] bi ; inline
[ nip ]
2tri ; inline
: <WSASendTo-args> ( packet addrspec datagram -- WSASendTo ) : <WSASendTo-args> ( packet addrspec datagram -- WSASendTo )
WSASendTo-args new WSASendTo-args new

View File

@ -195,9 +195,9 @@ C-STRUCT: FLOWSPEC
TYPEDEF: FLOWSPEC* PFLOWSPEC TYPEDEF: FLOWSPEC* PFLOWSPEC
TYPEDEF: FLOWSPEC* LPFLOWSPEC TYPEDEF: FLOWSPEC* LPFLOWSPEC
C-STRUCT: WSABUF STRUCT: WSABUF
{ "ulong" "len" } { len ulong }
{ "void*" "buf" } ; { buf void* } ;
TYPEDEF: WSABUF* LPWSABUF TYPEDEF: WSABUF* LPWSABUF
C-STRUCT: QOS C-STRUCT: QOS