Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/planix-v0/sys/src/cmd/cec/utils.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
#include "cec.h"
4
 
5
static	int	fd	= -1;
6
extern	char	*svc;
7
 
8
void
9
rawon(void)
10
{
11
	if(svc)
12
		return;
13
	if((fd = open("/dev/consctl", OWRITE)) == -1 ||
14
	    write(fd, "rawon", 5) != 5)
15
		fprint(2, "Can't make console raw\n");
16
}
17
 
18
void
19
rawoff(void)
20
{
21
	if(svc)
22
		return;
23
	close(fd);
24
}
25
 
26
enum {
27
	Perline	= 16,
28
	Perch	= 3,
29
};
30
 
31
char	line[Perch*Perline+1];
32
 
33
static void
34
format(uchar *buf, int n, int t)
35
{
36
	int i, r;
37
 
38
	for(i = 0; i < n; i++){
39
		r = (i + t) % Perline;
40
		if(r == 0 && i + t > 0)
41
			fprint(2, "%s\n", line);
42
		sprint(line + r*Perch, "%.2x ", buf[i]);
43
	}
44
}
45
 
46
void
47
dump(uchar *p, int n)
48
{
49
	format(p, n, 0);
50
	if(n % 16 > 0)
51
		print("%s\n", line);
52
}