diff options
Diffstat (limited to 'src/entropy/beos_stats/es_beos.cpp')
-rw-r--r-- | src/entropy/beos_stats/es_beos.cpp | 46 |
1 files changed, 14 insertions, 32 deletions
diff --git a/src/entropy/beos_stats/es_beos.cpp b/src/entropy/beos_stats/es_beos.cpp index b5a5e7fee..02a751e6a 100644 --- a/src/entropy/beos_stats/es_beos.cpp +++ b/src/entropy/beos_stats/es_beos.cpp @@ -4,7 +4,6 @@ */ #include <botan/es_beos.h> -#include <botan/xor_buf.h> #include <kernel/OS.h> #include <kernel/image.h> @@ -13,69 +12,52 @@ namespace Botan { /** -* BeOS Fast Poll +* BeOS entropy poll */ -u32bit BeOS_EntropySource::fast_poll(byte buf[], u32bit length) +void BeOS_EntropySource::poll(Entropy_Accumulator& accum) { - if(length == 0) - return 0; - length = std::min<u32bit>(length, 32); - - u32bit buf_i = 0; - system_info info_sys; get_system_info(&info_sys); - buf_i = xor_into_buf(buf, buf_i, length, info_sys); + accum.add(info_sys, 2); - key_info info_key; + key_info info_key; // current state of the keyboard get_key_info(&info_key); - buf_i = xor_into_buf(buf, buf_i, length, key_info); - - buf_i = xor_into_buf(buf, buf_i, length, idle_time()); - - return length; - } + accum.add(info_key, 0); -/** -* BeOS slow poll -*/ -u32bit BeOS_EntropySource::slow_poll(byte buf[], u32bit length) - { - if(length == 0) - return 0; + accum.add(idle_time(), 0); - u32bit buf_i = 0; team_info info_team; int32 cookie_team = 0; while(get_next_team_info(&cookie_team, &info_team) == B_OK) { - buf_i = xor_into_buf(buf, buf_i, length, info_team); + accum.add(info_team, 2); team_id id = info_team.team; int32 cookie = 0; thread_info info_thr; while(get_next_thread_info(id, &cookie, &info_thr) == B_OK) - buf_i = xor_into_buf(buf, buf_i, length, info_thr); + accum.add(info_thr, 1); cookie = 0; image_info info_img; while(get_next_image_info(id, &cookie, &info_img) == B_OK) - buf_i = xor_into_buf(buf, buf_i, length, info_img); + accum.add(info_img, 1); cookie = 0; sem_info info_sem; while(get_next_sem_info(id, &cookie, &info_sem) == B_OK) - buf_i = xor_into_buf(buf, buf_i, length, info_sem); + accum.add(info_sem, 1); cookie = 0; area_info info_area; while(get_next_area_info(id, &cookie, &info_area) == B_OK) - buf_i = xor_into_buf(buf, buf_i, length, info_area); - } + accum.add(info_area, 2); - return length; + if(accum.polling_goal_achieved()) + break; + } } } |