1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
$NetBSD: patch-as,v 1.1 1999/01/11 01:11:22 abs Exp $
--- kcontrol/info.orig/processor_netbsd.cpp Wed Dec 31 16:00:00 1969
+++ kcontrol/info/processor_netbsd.cpp Sun Jan 10 16:27:32 1999
@@ -0,0 +1,59 @@
+#include <stdlib.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+typedef struct
+ {
+ int string;
+ int name;
+ char *title;
+ } hw_info_mib_list_t;
+
+KProcessorWidget::KProcessorWidget(QWidget *parent, const char *name)
+ : KConfigWidget(parent, name)
+{
+ static hw_info_mib_list_t hw_info_mib_list[]= {
+ { 1, HW_MODEL, "Model : " },
+ { 1, HW_MACHINE, "Machine : " },
+ { 1, HW_MACHINE_ARCH, "Architecture : " },
+ { 0, HW_NCPU, "Number of CPUs : " },
+ { 0, HW_PAGESIZE, "Pagesize : " },
+ { 0,0,0 }
+ };
+ hw_info_mib_list_t *hw_info_mib;
+
+ int mib[2], num;
+ char *buf, numbuf[sizeof(num)*3+1];
+ size_t len;
+
+ lBox = new QListBox(this);
+ lBox->setGeometry(20,20,400,280);
+ lBox->setFont(QFont("Courier"));
+
+ for ( hw_info_mib = hw_info_mib_list ; hw_info_mib->title ; ++hw_info_mib )
+ {
+ mib[0] = CTL_HW;
+ mib[1] = hw_info_mib->name;
+ if ( hw_info_mib->string )
+ {
+ sysctl(mib,2,NULL,&len,NULL,0);
+ if ( (buf = (char*)malloc(len)) )
+ {
+ sysctl(mib,2,buf,&len,NULL,0);
+ lBox->insertItem(QString(hw_info_mib->title) + QString(buf));
+ free(buf);
+ }
+ else
+ lBox->insertItem(QString(hw_info_mib->title) + QString("Unknown"));
+ }
+ else
+ {
+ len = sizeof(num);
+ sysctl(mib,2,&num,&len,NULL,0);
+ sprintf(numbuf,"%d",num);
+ lBox->insertItem(QString(hw_info_mib->title) + QString(numbuf));
+ }
+ }
+}
+
|