-// this file contains code copied from linux.pp in the free pascal rtl\r
-// i had to copy them because i use a different definition of fdset to them\r
-// the copyright block from the file in question is shown below\r
-{\r
- $Id: fd_utils.pas,v 1.2 2004/08/19 23:12:09 plugwash Exp $\r
- This file is part of the Free Pascal run time library.\r
- Copyright (c) 1999-2000 by Michael Van Canneyt,\r
- BSD parts (c) 2000 by Marco van de Voort\r
- members of the Free Pascal development team.\r
-\r
- See the file COPYING.FPC, included in this distribution,\r
- for details about the copyright.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY;without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r
-\r
-**********************************************************************}\r
-{$ifdef fpc}\r
- {$mode delphi}\r
- {$inlining on}\r
-{$endif}\r
-unit fd_utils;\r
-interface\r
-\r
-type\r
- FDSet= Array [0..255] of longint; {31}\r
- PFDSet= ^FDSet;\r
-const\r
- absoloutemaxs=(sizeof(fdset)*8)-1;\r
-\r
-Procedure FD_Clr(fd:longint;var fds:fdSet);\r
-Procedure FD_Zero(var fds:fdSet);\r
-Procedure FD_Set(fd:longint;var fds:fdSet);\r
-Function FD_IsSet(fd:longint;var fds:fdSet):boolean;\r
-\r
-\r
-implementation \r
-uses sysutils;\r
-Procedure FD_Clr(fd:longint;var fds:fdSet);{$ifdef fpc}inline;{$endif}\r
-{ Remove fd from the set of filedescriptors}\r
-begin\r
- if (fd < 0) then raise exception.create('FD_Clr fd out of range: '+inttostr(fd));\r
- fds[fd shr 5]:=fds[fd shr 5] and (not (1 shl (fd and 31)));\r
-end;\r
-\r
-Procedure FD_Zero(var fds:fdSet);\r
-{ Clear the set of filedescriptors }\r
-begin\r
- FillChar(fds,sizeof(fdSet),0);\r
-end;\r
-\r
-Procedure FD_Set(fd:longint;var fds:fdSet);{$ifdef fpc}inline;{$endif}\r
-{ Add fd to the set of filedescriptors }\r
-begin\r
- if (fd < 0) then raise exception.create('FD_set fd out of range: '+inttostr(fd));\r
- fds[fd shr 5]:=fds[fd shr 5] or (1 shl (fd and 31));\r
-end;\r
-\r
-Function FD_IsSet(fd:longint;var fds:fdSet):boolean;{$ifdef fpc}inline;{$endif}\r
-{ Test if fd is part of the set of filedescriptors }\r
-begin\r
- if (fd < 0) then begin\r
- result := false;\r
- exit;\r
- end;\r
- FD_IsSet:=((fds[fd shr 5] and (1 shl (fd and 31)))<>0);\r
-end;\r
-end.\r