15
/* current args for next start() */
16
static char *geometry;
17
static char *dpy_name;
18
static char *vbi_name = "/dev/vbi";
19
static struct xio *xio;
20
static struct vbi *vbi;
21
static int fine_tune = 1; // auto = 999;
23
static int newbttv = -1;
27
usage(FILE *fp, int exitval)
29
fprintf(fp, "\nUsage: %s [options]\n", prgname);
32
" Valid options:\t\tDefault:\n"
35
" -vbi <vbidev>\t\t/dev/vbi\n"
36
" -display <dpy>\t\t$DISPLAY\n"
37
" -geometry <geo>\t\t41x25\n"
38
" -finetune <-4..4|auto>\t0\n"
40
" [-parent] ppp[.ss]\t\t900\n"
41
//" -oldbttv\t\t(for bttv <0.5.20)\n"
42
" -[no]erc\t\t\tenabled\n"
43
" -[no]bell\t\t\tenabled\n"
44
" -charset latin-1/2\t\tlatin-1\n"
46
" Order is important! Each page number\n"
47
" opens a new window with the previously\n"
48
" given geometry, device, and display.\n"
50
" ppp[.ss] stands for a page number and an\n"
51
" optional subpage number (ie 123.4). If\n"
52
" the subpage number is omitted the first\n"
53
" transmitted subpage is shown.\n"
55
" The -child option requires a parent\n"
56
" window. So, it must be preceeded by\n"
57
" a parent or another child window.\n"
64
arg_pgno(char *p, int *subno)
72
pgno = strtol(p, &end, 16);
73
if ((*end == ':' || *end == '/' || *end == '.') && end[1])
74
*subno = strtol(end + 1, &end, 16);
76
if (pgno >= 0x100 && pgno <= 0x999)
77
if (*subno == ANY_SUB || (*subno >= 0x00 && *subno <= 0x3f7f))
80
fatal("%s: invalid page number", p);
85
start(int argc, char **argv, struct vtwin *parent, int pgno, int subno)
90
vbi = vbi_open(vbi_name, cache_open(), fine_tune, newbttv);
92
fatal("cannot open %s", vbi_name);
94
vbi->cache->op->mode(vbi->cache, CACHE_MODE_ERC, erc);
97
xio = xio_open_dpy(dpy_name, argc, argv);
99
fatal("cannot open display");
101
parent = vtwin_new(xio, vbi, geometry, parent, pgno, subno);
103
fatal("cannot create window");
109
option(int argc, char **argv, int *ind, char **arg)
111
static struct { char *nam, *altnam; int arg; } opts[] = {
112
{ "-vbi", "-dev", 1 },
113
{ "-display", "-d", 1 },
114
{ "-geometry", "-g", 1 },
115
{ "-child", "-c", 1 },
116
{ "-editor", "-ed", 0 },
117
{ "-parent", "-p", 1 },
118
{ "--version", "-v", 0 },
119
{ "--help", "-h", 0 },
120
{ "-newbttv", "-new", 0 },
121
{ "-oldbttv", "-old", 0 },
122
{ "-finetune", "-f", 1 },
123
{ "-debug", "--debug", 0 },
124
{ "-copyright", "-�", 0 },
126
{ "-noerc", "-ne", 0 },
127
{ "-bell", "-b", 0 },
128
{ "-nobell", "-nb", 0 },
129
{ "-charset", "-latin", 1 },
136
*arg = argv[(*ind)++];
137
for (i = 0; i < NELEM(opts); ++i)
138
if (streq(*arg, opts[i].nam) || streq(*arg, opts[i].altnam))
142
*arg = argv[(*ind)++];
144
fatal("option %s requires an argument", *arg);
150
fatal("%s: invalid option", *arg);
160
main(int argc, char **argv)
162
struct vtwin *parent = 0;
172
while (opt = option(argc, argv, &ind, &arg))
190
fatal("-child requires a parent window");
191
pgno = arg_pgno(arg, &subno);
192
parent = start(argc, argv, parent, pgno, subno);
199
printf("AleVT Version "VERSION"\n");
201
case 13: // copyright
202
printf("Copyright 2000 by E. Toernig, froese@gmx.de\n");
214
if (streq(arg, "auto"))
217
fine_tune = strtol(arg, 0, 10);
232
if (streq(arg, "latin-1") || streq(arg, "1"))
234
else if (streq(arg, "latin-2") || streq(arg, "2"))
237
fatal("bad charset (not latin-1/2)");
243
case -1: // non-option arg
244
pgno = arg_pgno(arg, &subno);
245
parent = start(argc, argv, 0, pgno, subno);
251
start(argc, argv, 0, 0x900, ANY_SUB);