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/feature_tlsv12/sys/src/cmd/sam/plan9.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 "sam.h"
2
 
3
Rune	samname[] = L"~~sam~~";
4
 
5
Rune *left[]= {
6
	L"{[(<«",
7
	L"\n",
8
	L"'\"`",
9
 
10
};
11
Rune *right[]= {
12
	L"}])>»",
13
	L"\n",
14
	L"'\"`",
15
 
16
};
17
 
18
char	RSAM[] = "sam";
19
char	SAMTERM[] = "/bin/aux/samterm";
20
char	HOME[] = "home";
21
char	TMPDIR[] = "/tmp";
22
char	SH[] = "rc";
23
char	SHPATH[] = "/bin/rc";
24
char	RX[] = "rx";
25
char	RXPATH[] = "/bin/rx";
26
char	SAMSAVECMD[] = "/bin/rc\n/sys/lib/samsave";
27
 
28
void
29
dprint(char *z, ...)
30
{
31
	char buf[BLOCKSIZE];
32
	va_list arg;
33
 
34
	va_start(arg, z);
35
	vseprint(buf, &buf[BLOCKSIZE], z, arg);
36
	va_end(arg);
37
	termwrite(buf);
38
}
39
 
40
void
41
print_ss(char *s, String *a, String *b)
42
{
43
	dprint("?warning: %s: `%.*S' and `%.*S'\n", s, a->n, a->s, b->n, b->s);
44
}
45
 
46
void
47
print_s(char *s, String *a)
48
{
49
	dprint("?warning: %s `%.*S'\n", s, a->n, a->s);
50
}
51
 
52
int
53
statfile(char *name, ulong *dev, uvlong *id, long *time, long *length, long *appendonly)
54
{
55
	Dir *dirb;
56
 
57
	dirb = dirstat(name);
58
	if(dirb == nil)
59
		return -1;
60
	if(dev)
61
		*dev = dirb->type|(dirb->dev<<16);
62
	if(id)
63
		*id = dirb->qid.path;
64
	if(time)
65
		*time = dirb->mtime;
66
	if(length)
67
		*length = dirb->length;
68
	if(appendonly)
69
		*appendonly = dirb->mode & DMAPPEND;
70
	free(dirb);
71
	return 1;
72
}
73
 
74
int
75
statfd(int fd, ulong *dev, uvlong *id, long *time, long *length, long *appendonly)
76
{
77
	Dir *dirb;
78
 
79
	dirb = dirfstat(fd);
80
	if(dirb == nil)
81
		return -1;
82
	if(dev)
83
		*dev = dirb->type|(dirb->dev<<16);
84
	if(id)
85
		*id = dirb->qid.path;
86
	if(time)
87
		*time = dirb->mtime;
88
	if(length)
89
		*length = dirb->length;
90
	if(appendonly)
91
		*appendonly = dirb->mode & DMAPPEND;
92
	free(dirb);
93
	return 1;
94
}
95
 
96
void
97
notifyf(void *a, char *s)
98
{
99
	USED(a);
100
	if(bpipeok && strcmp(s, "sys: write on closed pipe") == 0)
101
		noted(NCONT);
102
	if(strcmp(s, "interrupt") == 0)
103
		noted(NCONT);
104
	panicking = 1;
105
	rescue();
106
	noted(NDFLT);
107
}
108
 
109
char*
110
waitfor(int pid)
111
{
112
	Waitmsg *w;
113
	static char msg[ERRMAX];
114
 
115
	while((w = wait()) != nil){
116
		if(w->pid != pid){
117
			free(w);
118
			continue;
119
		}
120
		strecpy(msg, msg+sizeof msg, w->msg);
121
		free(w);
122
		return msg;
123
	}
124
	rerrstr(msg, sizeof msg);
125
	return msg;
126
}
127
 
128
void
129
samerr(char *buf)
130
{
131
	sprint(buf, "%s/sam.err", TMPDIR);
132
}
133
 
134
void*
135
emalloc(ulong n)
136
{
137
	void *p;
138
 
139
	p = malloc(n);
140
	if(p == 0)
141
		panic("malloc fails");
142
	memset(p, 0, n);
143
	return p;
144
}
145
 
146
void*
147
erealloc(void *p, ulong n)
148
{
149
	p = realloc(p, n);
150
	if(p == 0)
151
		panic("realloc fails");
152
	return p;
153
}