1 /** 2 * BeOS EntropySource 3 * 4 * Copyright: 5 * (C) 1999-2008 Jack Lloyd 6 * (C) 2014-2015 Etienne Cimon 7 * 8 * License: 9 * Botan is released under the Simplified BSD License (see LICENSE.md) 10 */ 11 module botan.entropy.es_beos; 12 13 import botan.constants; 14 static if (BOTAN_HAS_ENTROPY_SRC_BEOS): 15 import botan.entropy.entropy_src; 16 17 /** 18 * BeOS Entropy Source 19 */ 20 final class BeOSEntropySource : EntropySource 21 { 22 private: 23 @property string name() const { return "BeOS Statistics"; } 24 25 /** 26 * BeOS entropy poll 27 */ 28 void poll(ref EntropyAccumulator accum) 29 { 30 system_info info_sys; 31 get_system_info(&info_sys); 32 accum.add(info_sys, 2); 33 34 key_info info_key; // current state of the keyboard 35 get_key_info(&info_key); 36 accum.add(info_key, 0); 37 38 team_info info_team; 39 int32 cookie_team = 0; 40 41 while (get_next_team_info(&cookie_team, &info_team) == B_OK) 42 { 43 accum.add(info_team, 2); 44 45 team_id id = info_team.team; 46 int32 cookie = 0; 47 48 thread_info info_thr; 49 while (get_next_thread_info(id, &cookie, &info_thr) == B_OK) 50 accum.add(info_thr, 1); 51 52 cookie = 0; 53 image_info info_img; 54 while (get_next_image_info(id, &cookie, &info_img) == B_OK) 55 accum.add(info_img, 1); 56 57 cookie = 0; 58 sem_info info_sem; 59 while (get_next_sem_info(id, &cookie, &info_sem) == B_OK) 60 accum.add(info_sem, 1); 61 62 cookie = 0; 63 area_info info_area; 64 while (get_next_area_info(id, &cookie, &info_area) == B_OK) 65 accum.add(info_area, 2); 66 67 if (accum.pollingGoalAchieved()) 68 break; 69 } 70 } 71 72 }