diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
commit | ec05778d5718a7912e506764d443a78d6a6179e3 (patch) | |
tree | 78a9a01532180030c095acefc45763f07c14edb8 /src/stable/randomsystem.cpp | |
parent | b20414ac1fe80a71a90601f4cd1767fa7014a9ba (diff) | |
download | libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.gz libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.bz2 libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.xz libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.zip |
Converted tabs to spaces with tabconv.
Diffstat (limited to 'src/stable/randomsystem.cpp')
-rw-r--r-- | src/stable/randomsystem.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/stable/randomsystem.cpp b/src/stable/randomsystem.cpp index 0501587..68c69d5 100644 --- a/src/stable/randomsystem.cpp +++ b/src/stable/randomsystem.cpp | |||
@@ -2,39 +2,39 @@ | |||
2 | #include "bu/file.h" | 2 | #include "bu/file.h" |
3 | 3 | ||
4 | Bu::RandomSystem::RandomSystem( Type eType ) : | 4 | Bu::RandomSystem::RandomSystem( Type eType ) : |
5 | eType( eType ), | 5 | eType( eType ), |
6 | pSrc( 0 ) | 6 | pSrc( 0 ) |
7 | { | 7 | { |
8 | switch( eType ) | 8 | switch( eType ) |
9 | { | 9 | { |
10 | case Bu::RandomSystem::Fast: | 10 | case Bu::RandomSystem::Fast: |
11 | pSrc = new Bu::File("/dev/urandom", Bu::File::Read ); | 11 | pSrc = new Bu::File("/dev/urandom", Bu::File::Read ); |
12 | break; | 12 | break; |
13 | 13 | ||
14 | case Bu::RandomSystem::Good: | 14 | case Bu::RandomSystem::Good: |
15 | pSrc = new Bu::File("/dev/random", Bu::File::Read ); | 15 | pSrc = new Bu::File("/dev/random", Bu::File::Read ); |
16 | break; | 16 | break; |
17 | } | 17 | } |
18 | } | 18 | } |
19 | 19 | ||
20 | Bu::RandomSystem::~RandomSystem() | 20 | Bu::RandomSystem::~RandomSystem() |
21 | { | 21 | { |
22 | delete pSrc; | 22 | delete pSrc; |
23 | } | 23 | } |
24 | 24 | ||
25 | void Bu::RandomSystem::seed( int32_t /*iSeed*/ ) | 25 | void Bu::RandomSystem::seed( int32_t /*iSeed*/ ) |
26 | { | 26 | { |
27 | // Seed really has no effect here... | 27 | // Seed really has no effect here... |
28 | // on linux, if we were root, we could write data to random/urandom to | 28 | // on linux, if we were root, we could write data to random/urandom to |
29 | // perturb the data, but it's not necesarry | 29 | // perturb the data, but it's not necesarry |
30 | } | 30 | } |
31 | 31 | ||
32 | int32_t Bu::RandomSystem::rand() | 32 | int32_t Bu::RandomSystem::rand() |
33 | { | 33 | { |
34 | if( !pSrc ) | 34 | if( !pSrc ) |
35 | throw Bu::ExceptionBase("Not initialized"); | 35 | throw Bu::ExceptionBase("Not initialized"); |
36 | int32_t i; | 36 | int32_t i; |
37 | pSrc->read( &i, sizeof(int32_t) ); | 37 | pSrc->read( &i, sizeof(int32_t) ); |
38 | return i; | 38 | return i; |
39 | } | 39 | } |
40 | 40 | ||