1 // TCP/IP stack for winDOS
2 // ftp://ftp.delorie.com/pub/djgpp/current/v2tk/ls080b.zip
3 // ftp://ftp.delorie.com/pub/djgpp/current/v2tk/ls080d.zip
4 // ftp://ftp.delorie.com/pub/djgpp/current/v2tk/ls080s.zip
13 {$LINKLIB libsocket.a}
15 {$DEFINE LibraryLibSockDecl := cdecl}
16 {$DEFINE LibraryLibSockImp := cdecl; external}
17 {$DEFINE LibraryLibSockVar := cvar; external}
25 (* Start-up & shutdown *)
26 function __lsck_init
: cint
; LibraryLibSockImp
;
27 procedure __lsck_uninit
; LibraryLibSockImp
;
30 function __lsck_config_getdir
: PChar; LibraryLibSockImp
;
31 function __lsck_config_setdir (newdir
: PChar): PChar; LibraryLibSockImp
;
32 function __lsck_config_getfile
: PChar; LibraryLibSockImp
;
33 function __lsck_config_setfile (newfile
: PChar): PChar; LibraryLibSockImp
;
36 function __lsck_getdnsaddr
: PChar; LibraryLibSockImp
;
37 function __lsck_getdnsaddrs
: PPChar
; LibraryLibSockImp
;
40 //function lsck_strerror (errnum: cint): PChar; LibraryLibSockImp;
41 function lsck_strerror (errnum
: cint
): PChar; LibraryLibSockImp name
'strerror';
43 (* File descriptor tests *)
44 function __fd_is_socket (fd
: cint
): cint
; LibraryLibSockImp
;
45 function __fd_is_valid (fd
: cint
): cint
; LibraryLibSockImp
;
50 LSCK_DEBUG_NORMAL
= 1;
51 LSCK_DEBUG_VERBOSE
= 2;
52 LSCK_DEBUG_ON
= LSCK_DEBUG_NORMAL
;
54 procedure __lsck_debug_setlevel (level
: cint
); LibraryLibSockImp
;
55 function __lsck_debug_getlevel
: cint
; LibraryLibSockImp
;
56 procedure __lsck_debug_enable
; LibraryLibSockImp
;
57 procedure __lsck_debug_disable
; LibraryLibSockImp
;
58 function __lsck_debug_enabled
: cint
; LibraryLibSockImp
;
61 function __lsck_get_version
: PChar; LibraryLibSockImp
;
62 function __lsck_get_copyright
: PChar; LibraryLibSockImp
;
65 function getdomainname (name
: PChar; len
: csize_t
): cint
; LibraryLibSockImp
;
66 function setdomainname (const name
: PChar; len
: csize_t
): cint
; LibraryLibSockImp
;
69 function gethostname (buf
: PChar; size
: cint
): cint
; LibraryLibSockImp
;
70 function sethostname (buf
: PChar; size
: cint
): cint
; LibraryLibSockImp
;
77 function htonl (_val
: culong
): culong
; LibraryLibSockImp
;
78 function ntohl (_val
: culong
): culong
; LibraryLibSockImp
;
79 function htons (_val
: cushort
): cushort
; LibraryLibSockImp
;
80 function ntohs (_val
: cushort
): cushort
; LibraryLibSockImp
;
86 FD_MAXFDSET
= 256; (* FD_SETSIZE *)
89 (* djgpp sys-include -> sys/wtypes.h -> fd_set *)
91 fd_bits
: array [0..(FD_MAXFDSET
+ 7) DIV 8] of cuchar
;
94 function fpFD_SET (fdno
: cint
; var nset
: TFDSet
): cint
;
95 function fpFD_CLR (fdno
: cint
; var nset
: TFDSet
): cint
;
96 function fpFD_ZERO (out nset
: TFDSet
): cint
;
97 function fpFD_ISSET (fdno
: cint
; const nset
: TFDSet
): cint
;
101 function fpFD_SET (fdno
: cint
; var nset
: TFDSet
): cint
;
103 if (fdno
< 0) or (fdno
> FD_MAXFDSET
) then
105 nset
.fd_bits
[fdno
div 8] := nset
.fd_bits
[fdno
div 8] OR (culong(1) shl (fdno
and 7));
109 function fpFD_CLR (fdno
: cint
; var nset
: TFDSet
): cint
;
111 if (fdno
< 0) or (fdno
> FD_MAXFDSET
) Then
113 nset
.fd_bits
[fdno
div 8] := nset
.fd_bits
[fdno
div 8] AND Cardinal(NOT (culong(1) shl (fdno
and 7)));
117 function fpFD_ZERO (out nset
: TFDSet
): cint
;
120 for i
:= 0 to (FD_MAXFDSET
+ 7) div 8 DO
121 nset
.fd_bits
[i
] := 0;
125 function fpFD_ISSET (fdno
: cint
; const nset
: TFDSet
): cint
;
127 if (fdno
< 0) or (fdno
> FD_MAXFDSET
) Then
129 if ((nset
.fd_bits
[fdno
div 8]) and (culong(1) shl (fdno
and 7))) > 0 then