-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdevdrawserver.c
More file actions
76 lines (61 loc) · 1.14 KB
/
devdrawserver.c
File metadata and controls
76 lines (61 loc) · 1.14 KB
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
#include <u.h>
#include <libc.h>
#include <thread.h>
#include <draw.h>
#include <memdraw.h>
#include <keyboard.h>
#include <mouse.h>
#include <cursor.h>
#include <drawfcall.h>
#include "fcall.h"
void serve();
void rmsock();
static char sockpath[200];
void
usage()
{
fprint(2, "usage: %s\n", argv0);
threadexitsall("usage");
}
void
threadmain(int argc, char **argv)
{
fmtinstall('W', drawfcallfmt);
fmtinstall('H', encodefmt);
// snprint(sockpath, sizeof sockpath, "%s/devdrawserver", getns());
strcpy(sockpath, "/tmp/devdrawserver");
serve();
threadexitsall("");
}
void
rmsock()
{
if(remove(sockpath) < 0)
fprint(2, "remove: %r\n");
}
void
serve()
{
int afd, lfd;
char dir[100], adir[100], buf[200];
Alt a[3];
snprint(buf, sizeof buf, "unix!%s", sockpath);
atexit(rmsock);
if((afd = announce(buf, adir)) < 0)
sysfatal("announce: %r");
if ((lfd = listen(adir, dir)) < 0)
goto Error;
a[0].c = procproxyfcalls(lfd, 1);
a[0].op = CHANRCV;
a[1].c = procproxyfcalls(0, lfd);
a[1].op = CHANRCV;
a[2].op = CHANEND;
werrstr(a[alt(a)].v);
close(lfd);
Error:
close(afd);
threadexitsall("%r");
}
void
_flushmemscreen(Rectangle r)
{}