summaryrefslogtreecommitdiff
path: root/x11/kdebase2/patches/patch-an
blob: 5883122b8027f8b2a4266a7baa193f6334d2213d (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
$NetBSD: patch-an,v 1.3 2001/11/28 13:34:19 skrll Exp $

--- kcontrol/info/info_netbsd.cpp.orig	Fri Sep  7 20:23:47 2001
+++ kcontrol/info/info_netbsd.cpp
@@ -34,8 +34,10 @@
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/sysctl.h>
+#include <sys/mount.h>
 #include <stdio.h>	/* for NULL */
 #include <stdlib.h>	/* for malloc(3) */
+#include <fstab.h>
 
 #include <qfile.h>
 #include <qfontmetrics.h>
@@ -100,15 +102,14 @@
 // this is used to find out which devices are currently
 // on system
 static bool GetDmesgInfo(QListView *lBox, const char *filter,
-	void func(QListView *, QCString s, void **, bool))
+	void func(QListView *, QString s))
 {
         QFile *dmesg = new QFile("/var/run/dmesg.boot");
 	bool usepipe = false;
 	FILE *pipe = NULL;
 	QTextStream *t;
 	bool seencpu = false;
-	void *opaque = NULL;
-	QCString s;
+	QString s;
 	bool found = false;
 
 	if (dmesg->exists() && dmesg->open(IO_ReadOnly)) {
@@ -134,25 +135,20 @@
 			s.contains("WARNING: old BSD partition ID!"))
 			break;
 
-		if (!filter || s.contains(filter)) {
-			if (func) {
-				func(lBox, s, &opaque, false);
-			}
-			else {
+		if (!filter
+		    || (filter[0] == '^' && s.find(&filter[1]) == 0)
+		    || (filter[0] != '^' && s.contains(filter))) {
+			if (func)
+				func(lBox, s);
+			else
 				olditem = new QListViewItem(lBox, olditem, s);
-			}
 			found = true;
 		}
 	}
-	if (func) {
-		func(lBox, s, &opaque, true);
-	}
-	//lBox->triggerUpdate();
 
 	delete t;
-	if (pipe) {
+	if (pipe)
 		pclose(pipe);
-	}
 	else {
 		dmesg->close();
 		delete dmesg;
@@ -162,32 +158,31 @@
 }
 
 
-void AddIRQLine(QListView *lBox, QCString s, void **opaque, bool final)
+void
+AddIRQLine(QListView *lBox, QString s)
 {
-	if (!final) {
-		char str[3];
-		const char *p = s.data();
-		int pos = s.find(" irq ");
-		int irq = (pos<0) ? 0 : atoi(p+pos+5);
+	int pos, irqnum;
+	char numstr[3];
 
-		if (irq) {
-			sprintf(str, "%2d", irq);
-		}
-		else {
-			str[0] = str[1] = '?';
-			str[2] = 0;
-		}
-		new QListViewItem(lBox, str, p);
+	pos = s.find(" irq ");
+	irqnum = (pos < 0) ? 0 : atoi(&s.ascii()[pos+5]);
+	if (irqnum)
+		snprintf(numstr, 3, "%02d", irqnum);
+	else {
+		// this should never happen
+		strcpy(numstr, "??");
 	}
+
+	new QListViewItem(lBox, numstr, s);
 }
 
 bool GetInfo_IRQ (QListView *lBox)
 {
 	lBox->addColumn(i18n("IRQ"));
 	lBox->addColumn(i18n("Device"));
+	lBox->setSorting(0);
+	lBox->setShowSortIndicator(FALSE);
 	(void) GetDmesgInfo(lBox, " irq ", AddIRQLine);
-	sorting_allowed = true;
-	lBox->setSorting(1);
 	return true;
 }
 
@@ -212,26 +207,27 @@
 
 bool GetInfo_Sound (QListView *lbox)
 {
+	lbox->setSorting(false);
+
 	if (!GetDmesgInfo(lbox, "audio", NULL))
 		new QListViewItem(lbox, i18n("No audio devices found."));
 
-	// append information on any audio devices found
+	// append information for each audio devices found
 	QListViewItem *lvitem = lbox->firstChild();
 	for(; lvitem; lvitem = lvitem->nextSibling()) {
 		QString s;
 		int pos, len;
-		const char *start, *end;
+		const char *start;
 		char *dev;
 
 		s = lvitem->text(0);
-		if ((pos = s.find("at ")) >= 0) {
-			pos += 3;	// skip "at "
-			start = end = s.ascii();
-			for(; (*end!=':') && (*end!='\n'); end++);
-			len = end - start;
-			dev = (char *) malloc(len + 1);
-			strncpy(dev, start, len);
-			dev[len] = '\0';
+		// The autoconf message is in form 'audio0 at auvia0: ...'
+		if (s.find("audio") == 0 && (pos = s.find(" at ")) > 0) {
+			pos += 4;	// skip " at "
+			start = s.ascii() + pos;
+			len = (int) strcspn(start, ":\n\t ");
+			dev = (char *) malloc(1 + len + 1);
+			sprintf(dev, "^%.*s", len, start);	/* safe */
 
 			GetDmesgInfo(lbox, dev, NULL);
 
@@ -252,16 +248,32 @@
 {
 	if (!GetDmesgInfo(lbox, "scsibus", NULL))
 		new QListViewItem(lbox, i18n("No SCSI devices found."));
+
+	// remove the 'waiting %d seconds for devices to settle' message
+	QListViewItem *lvitem = lbox->firstChild();
+	for(; lvitem; lvitem = lvitem->nextSibling()) {
+		QString s = lvitem->text(0);
+
+		if (s.contains("seconds for devices to settle")) {
+			lbox->removeItem(lvitem);
+			break;
+		}
+	}
+	
 	return true;
 }
 
 bool GetInfo_Partitions (QListView *lbox)
 {
-	QCString s;
+	QString s;
+	QString MB;
 	char *line, *orig_line;
 	const char *device, *mountpoint, *type, *flags;
 	FILE *pipe = popen("/sbin/mount", "r");
 	QTextStream *t;
+	u_int64_t tsz, fsz;
+	struct statfs sfs;
+	int ok;
 
 	if (!pipe) {
 		kdError(0) << i18n("Ahh couldn't run /sbin/mount!") << endl;
@@ -269,14 +281,19 @@
 	}
 	t = new QTextStream(pipe, IO_ReadOnly);
 
+	MB = QString(" ") + QString(i18n("MB"));
 	lbox->addColumn(i18n("Device"));
 	lbox->addColumn(i18n("Mount Point"));
 	lbox->addColumn(i18n("FS Type"));
+	lbox->addColumn(i18n("Total Size"));
+	lbox->addColumn(i18n("Free Size"));
 	lbox->addColumn(i18n("Mount Options"));
 
-	QListViewItem *olditem = 0;
 	while (!(s = t->readLine().latin1()).isEmpty()) {
-		orig_line = line = strdup(s);
+		orig_line = line = strdup(s.ascii());
+
+		// the lines returned by /sbin/mount look like:
+		// /dev/wd0a on / type ffs (local, soft dependencies)
 
 		device = strsep(&line, " ");
 
@@ -286,10 +303,32 @@
 		(void) strsep(&line, " "); // consume word "type"
 		type = strsep(&line, " ");
 
-		flags = line;
 
-		olditem = new QListViewItem(lbox, olditem, device, mountpoint,
-					type, flags);
+		// Skip leading '(' and trailing ')'
+		if (line != NULL) {
+			line++;
+			flags = strsep(&line, ")");
+		} else {
+			flags = "";
+		}
+
+		if (statfs(mountpoint, &sfs) == 0) {
+			tsz = ((1LL * sfs.f_blocks * sfs.f_bsize / 1024) + 513)
+					/ 1024;
+			fsz = ((1LL * sfs.f_bfree * sfs.f_bsize / 1024) + 513)
+					/ 1024;
+			ok = 1;
+		} else {
+			tsz = fsz = 0;
+			ok = 0;
+		}
+
+		new QListViewItem(lbox,
+			QString(device) + " ",
+			QString(mountpoint) + " ", QString(type) + " ",
+			(ok) ? (Value(tsz, 6) + MB) : " ",
+			(ok) ? (Value(fsz, 6) + MB) : " ",
+			flags);
 
 		free(orig_line);
 	}