-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhovacui-main.c
64 lines (52 loc) · 1.4 KB
/
hovacui-main.c
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
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "cairoio.h"
#include "cairoio-fb.h"
#include "cairoio-drm.h"
#include "cairoio-x11.h"
#include "hovacui.h"
int main(int argn, char *argv[]) {
int opt;
struct cairodevice *cairodevice;
int cargn;
char **cargv;
char *usage;
/* collect usage of output devices */
usage = malloc(strlen(cairodevicefb.usage) + 1 +
strlen(cairodevicedrm.usage) + 1 +
strlen(cairodevicex11.usage) + 1);
strcpy(usage, "");
// strcat(usage, cairodevicefb.usage);
// strcat(usage, "\n");
strcat(usage, cairodevicedrm.usage);
strcat(usage, "\n");
strcat(usage, cairodevicex11.usage);
/* determine device */
cairodevice = NULL;
if (getenv("DISPLAY"))
cairodevice = &cairodevicex11;
opterr = 0;
cargv = malloc(argn * sizeof(char *));
optind = 1;
cargn = argn;
memcpy(cargv, argv, argn * sizeof(char *));
while (-1 != (opt = getopt(cargn, cargv, cairodevicedrm.options)))
if (opt != '?')
cairodevice = &cairodevicedrm;
optind = 1;
cargn = argn;
memcpy(cargv, argv, argn * sizeof(char *));
while (-1 != (opt = getopt(cargn, cargv, cairodevicex11.options)))
if (opt != '?')
cairodevice = &cairodevicex11;
free(cargv);
if (cairodevice == NULL) {
cairodevice = &cairodevicefb;
cairodevice->usage = usage;
}
/* run hovacui */
opterr = 1;
optind = 1;
return hovacui(argn, argv, cairodevice);
}