1 /* 2 This file was written by Loris Degioanni, and is part of Kismet 3 4 Kismet is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 9 Kismet is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with Kismet; if not, write to the Free Software 16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 */ 18 19 #include "config.h" 20 21 #ifndef __CYGWIN_UTILS_H__ 22 #define __CYGWIN_UTILS_H__ 23 24 #ifdef SYS_CYGWIN 25 26 #include <sys/time.h> 27 #include <sys/types.h> 28 #include <unistd.h> 29 30 class Handle2Fd { 31 public: 32 Handle2Fd(); 33 ~Handle2Fd(); 34 int AddHandle(HANDLE h); 35 void Signalread(); 36 int Activate(); 37 void Reset(); 38 int GetFd(); 39 int MergeSet(fd_set *set, int max); 40 int IsEventSet(unsigned int HandleNumber); 41 42 private: 43 #ifdef HANDLE2FD_INTERNAL 44 // The Unix side of cygwin doesn't like this 45 static DWORD WINAPI WaitThread(LPVOID lpParameter); 46 CRITICAL_SECTION PipeCs; 47 HANDLE WinHandles[MAXIMUM_WAIT_OBJECTS + 1]; 48 #endif 49 void SetPipe(); 50 void ResetPipe(); 51 52 int PipeFds[2]; 53 54 unsigned int NHandles; 55 56 HANDLE WaitThreadHandle; 57 HANDLE ReadEvent; 58 int ThreadAlive; 59 60 int PipeSignalled; 61 62 char ResetBuf[300]; 63 64 int FirstFdSet; 65 }; 66 67 #endif /* sys_cygwin */ 68 69 #endif 70 71