Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame^] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
| 2 | * |
| 3 | * This is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This software is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this software; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 16 | * USA. |
| 17 | */ |
| 18 | |
| 19 | #ifndef __RDR_RANDOMSTREAM_H__ |
| 20 | #define __RDR_RANDOMSTREAM_H__ |
| 21 | |
| 22 | #include <stdio.h> |
| 23 | #include <rdr/InStream.h> |
| 24 | |
| 25 | #ifdef WIN32 |
| 26 | #include <windows.h> |
| 27 | #include <wincrypt.h> |
| 28 | #ifdef WINCRYPT32API |
| 29 | #define RFB_HAVE_WINCRYPT |
| 30 | #endif |
| 31 | #endif |
| 32 | |
| 33 | namespace rdr { |
| 34 | |
| 35 | class RandomStream : public InStream { |
| 36 | |
| 37 | public: |
| 38 | |
| 39 | RandomStream(); |
| 40 | virtual ~RandomStream(); |
| 41 | |
| 42 | int pos(); |
| 43 | |
| 44 | protected: |
| 45 | int overrun(int itemSize, int nItems, bool wait); |
| 46 | |
| 47 | private: |
| 48 | U8* start; |
| 49 | int offset; |
| 50 | |
| 51 | static unsigned int seed; |
| 52 | #ifdef RFB_HAVE_WINCRYPT |
| 53 | HCRYPTPROV provider; |
| 54 | #endif |
| 55 | #ifndef WIN32 |
| 56 | FILE* fp; |
| 57 | #endif |
| 58 | |
| 59 | }; |
| 60 | |
| 61 | } // end of namespace rdr |
| 62 | |
| 63 | #endif |