-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample.txt
73 lines (60 loc) · 1.48 KB
/
sample.txt
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
// VNC Hooks
static void goneClient(rfbClientPtr client) {
client->clientData = NULL;
connectedClients--;
}
static enum rfbNewClientAction newClient(rfbClientPtr client) {
client->clientGoneHook = goneClient;
connectedClients++;
return RFB_CLIENT_ACCEPT;
}
// Count card entries
int countEntries() {
int entries = 0;
// Regular expression for /dev/dri/cardX
regex_t regExp;
regcomp(®Exp, "^card[0-9]*$", REG_NOSUB);
// Scan through /dev/dri to find card entries
DIR *dir = opendir("/dev/dri");
if(dir != NULL) {
struct dirent *dirEntry;
while ((dirEntry = readdir(dir))) {
if(!regexec(®Exp, dirEntry->d_name, 0, NULL, 0)) {
entries++;
}
}
} else {
printf("Couldn't open /dev/dri\n");
}
return entries++;
}
char * allocateVNCFramebuffer(rfbScreenInfoPtr screen) {
return buffer.buffer;
}
// Find available node
int findAvailableNode() {
int availableNode = -1;
do {
int cardEntries = countEntries();
for(int i = 0; i < cardEntries; i++) {
if (evdi_check_device(i) == AVAILABLE) {
availableNode = i;
goto end;
}
}
if(!evdi_add_device()) {
printf("Couldn't create evdi node. Check if evdi module is loaded.\n");
break;
}
} while(availableNode == -1);
end: ;
return availableNode;
}
// Open node
evdi_handle openNode() {
int entryNumber = findAvailableNode();
if(entryNumber == -1) {
return EVDI_INVALID_HANDLE;
}
return evdi_open(entryNumber);
}