55 |
volatile struct mapped_time_value *console_maptime; |
volatile struct mapped_time_value *console_maptime; |
56 |
|
|
57 |
#define DEFAULT_ENCODING "ISO-8859-1" |
#define DEFAULT_ENCODING "ISO-8859-1" |
58 |
|
#define DEFAULT_INTENSITY CONS_ATTR_INTENSITY_NORMAL |
59 |
|
#define DEFAULT_UNDERLINED 0 |
60 |
|
#define DEFAULT_BLINKING 0 |
61 |
|
#define DEFAULT_REVERSED 0 |
62 |
|
#define DEFAULT_CONCEALED 0 |
63 |
|
/* For the help output. */ |
64 |
|
#define DEFAULT_ATTRIBUTE_NAME "normal" |
65 |
#define DEFAULT_FOREGROUND CONS_COLOR_WHITE |
#define DEFAULT_FOREGROUND CONS_COLOR_WHITE |
66 |
/* For the help output. */ |
/* For the help output. */ |
67 |
#define DEFAULT_FOREGROUND_NAME "white" |
#define DEFAULT_FOREGROUND_NAME "white" |
116 |
vcons_t vcons_list; |
vcons_t vcons_list; |
117 |
/* The encoding. */ |
/* The encoding. */ |
118 |
char *encoding; |
char *encoding; |
119 |
/* Default foreground and background colors. */ |
/* Default attributes. */ |
120 |
int foreground; |
conchar_attr_t attribute; |
121 |
int background; |
|
|
|
|
122 |
/* Requester of directory modification notifications. */ |
/* Requester of directory modification notifications. */ |
123 |
struct modreq *dirmod_reqs; |
struct modreq *dirmod_reqs; |
124 |
unsigned int dirmod_tick; |
unsigned int dirmod_tick; |
221 |
|
|
222 |
mutex_init (&vcons->lock); |
mutex_init (&vcons->lock); |
223 |
err = display_create (&vcons->display, cons->encoding ?: DEFAULT_ENCODING, |
err = display_create (&vcons->display, cons->encoding ?: DEFAULT_ENCODING, |
224 |
cons->foreground, cons->background); |
cons->attribute); |
225 |
if (err) |
if (err) |
226 |
{ |
{ |
227 |
free (vcons->name); |
free (vcons->name); |
1300 |
|
|
1301 |
static const struct argp_option options[] = |
static const struct argp_option options[] = |
1302 |
{ |
{ |
1303 |
{ "foreground",'f', "COLOR", 0, "Set foreground color to" |
{ "foreground", 'f', "COLOR", 0, "Set foreground color to" |
1304 |
" COLOR (default `" DEFAULT_FOREGROUND_NAME "')" }, |
" COLOR (default `" DEFAULT_FOREGROUND_NAME "')" }, |
1305 |
{ "background",'b', "COLOR", 0, "Set background color to" |
{ "background", 'b', "COLOR", 0, "Set background color to" |
1306 |
" COLOR (default `" DEFAULT_BACKGROUND_NAME "')" }, |
" COLOR (default `" DEFAULT_BACKGROUND_NAME "')" }, |
1307 |
|
{ "attribute", 'a', "ATTR[,...]", 0, "Set further default attributes" |
1308 |
|
" (default `" DEFAULT_ATTRIBUTE_NAME "')" }, |
1309 |
{ "encoding", 'e', "NAME", 0, "Set encoding of virtual consoles to" |
{ "encoding", 'e', "NAME", 0, "Set encoding of virtual consoles to" |
1310 |
" NAME (default `" DEFAULT_ENCODING "')" }, |
" NAME (default `" DEFAULT_ENCODING "')" }, |
1311 |
{0} |
{0} |
1341 |
} |
} |
1342 |
|
|
1343 |
static error_t |
static error_t |
1344 |
|
parse_attributes (const char *name, conchar_attr_t *attr) |
1345 |
|
{ |
1346 |
|
while (*name) |
1347 |
|
{ |
1348 |
|
int value = 1; |
1349 |
|
|
1350 |
|
if (!strncmp (name, "not-", 4)) |
1351 |
|
{ |
1352 |
|
value = 0; |
1353 |
|
name += 4; |
1354 |
|
} |
1355 |
|
|
1356 |
|
if (!strncmp (name, "normal", 6)) |
1357 |
|
{ |
1358 |
|
name += 6; |
1359 |
|
if (value != 1) |
1360 |
|
return EINVAL; |
1361 |
|
attr->intensity = CONS_ATTR_INTENSITY_NORMAL; |
1362 |
|
} |
1363 |
|
else if (!strncmp (name, "bold", 4)) |
1364 |
|
{ |
1365 |
|
name += 4; |
1366 |
|
if (value != 1) |
1367 |
|
return EINVAL; |
1368 |
|
attr->intensity = CONS_ATTR_INTENSITY_BOLD; |
1369 |
|
} |
1370 |
|
else if (!strncmp (name, "dim", 3)) |
1371 |
|
{ |
1372 |
|
name += 3; |
1373 |
|
if (value != 1) |
1374 |
|
return EINVAL; |
1375 |
|
attr->intensity = CONS_ATTR_INTENSITY_DIM; |
1376 |
|
} |
1377 |
|
else if (!strncmp (name, "underlined", 10)) |
1378 |
|
{ |
1379 |
|
name += 10; |
1380 |
|
attr->underlined = value; |
1381 |
|
} |
1382 |
|
else if (!strncmp (name, "blinking", 8)) |
1383 |
|
{ |
1384 |
|
name += 8; |
1385 |
|
attr->blinking = value; |
1386 |
|
} |
1387 |
|
else if (!strncmp (name, "concealed", 9)) |
1388 |
|
{ |
1389 |
|
name += 9; |
1390 |
|
attr->concealed = value; |
1391 |
|
} |
1392 |
|
else |
1393 |
|
return EINVAL; |
1394 |
|
|
1395 |
|
if (name[0] == ',') |
1396 |
|
name++; |
1397 |
|
else if (name[0] != '\0') |
1398 |
|
return EINVAL; |
1399 |
|
} |
1400 |
|
return 0; |
1401 |
|
} |
1402 |
|
|
1403 |
|
static error_t |
1404 |
parse_opt (int opt, char *arg, struct argp_state *state) |
parse_opt (int opt, char *arg, struct argp_state *state) |
1405 |
{ |
{ |
1406 |
cons_t cons = state->input; |
cons_t cons = state->input; |
1407 |
|
error_t err; |
1408 |
|
int color = 0; |
1409 |
|
|
1410 |
switch (opt) |
switch (opt) |
1411 |
{ |
{ |
1424 |
break; |
break; |
1425 |
|
|
1426 |
case 'f': |
case 'f': |
1427 |
return parse_color (arg, &cons->foreground); |
err = parse_color (arg, &color); |
1428 |
|
cons->attribute.fgcol = color; |
1429 |
|
if (err) |
1430 |
|
argp_error (state, "Invalid color name: %s", arg); |
1431 |
|
break; |
1432 |
|
|
1433 |
case 'b': |
case 'b': |
1434 |
return parse_color (arg, &cons->background); |
err = parse_color (arg, &color); |
1435 |
|
cons->attribute.bgcol = color; |
1436 |
|
if (err) |
1437 |
|
argp_error (state, "Invalid color name: %s", arg); |
1438 |
|
break; |
1439 |
|
|
1440 |
|
case 'a': |
1441 |
|
err = parse_attributes (arg, &cons->attribute); |
1442 |
|
if (err) |
1443 |
|
argp_error (state, "Invalid attribute specifier: %s", arg); |
1444 |
|
break; |
1445 |
|
|
1446 |
case 'e': |
case 'e': |
1447 |
/* XXX Check validity of encoding. Can we perform all necessary |
/* XXX Check validity of encoding. Can we perform all necessary |
1467 |
{ |
{ |
1468 |
error_t err = 0; |
error_t err = 0; |
1469 |
cons_t cons = netfs_root_node->nn->cons; |
cons_t cons = netfs_root_node->nn->cons; |
1470 |
|
/* The longest possible is 61 characters long: |
1471 |
|
"normal,not-underlined,not-blinking,not-reversed,not-concealed". */ |
1472 |
|
char attr_str[80] = "--attribute="; |
1473 |
|
char *attr = &attr_str[12]; |
1474 |
|
char *attrp = attr; |
1475 |
|
|
1476 |
if (cons->encoding && strcmp (cons->encoding, DEFAULT_ENCODING)) |
if (cons->encoding && strcmp (cons->encoding, DEFAULT_ENCODING)) |
1477 |
{ |
{ |
1482 |
else |
else |
1483 |
err = errno; |
err = errno; |
1484 |
} |
} |
1485 |
if (cons->foreground != DEFAULT_FOREGROUND) |
if (!err && cons->attribute.fgcol != DEFAULT_FOREGROUND) |
1486 |
{ |
{ |
1487 |
char *buf; |
char *buf; |
1488 |
asprintf (&buf, "--foreground=%s", color_names[cons->foreground]); |
asprintf (&buf, "--foreground=%s", color_names[cons->attribute.fgcol]); |
1489 |
if (buf) |
if (buf) |
1490 |
err = argz_add (argz, argz_len, buf); |
err = argz_add (argz, argz_len, buf); |
1491 |
else |
else |
1492 |
err = errno; |
err = errno; |
1493 |
} |
} |
1494 |
if (cons->background != DEFAULT_BACKGROUND) |
if (!err && cons->attribute.bgcol != DEFAULT_BACKGROUND) |
1495 |
{ |
{ |
1496 |
char *buf; |
char *buf; |
1497 |
asprintf (&buf, "--background=%s", color_names[cons->background]); |
asprintf (&buf, "--background=%s", color_names[cons->attribute.bgcol]); |
1498 |
if (buf) |
if (buf) |
1499 |
err = argz_add (argz, argz_len, buf); |
err = argz_add (argz, argz_len, buf); |
1500 |
else |
else |
1501 |
err = errno; |
err = errno; |
1502 |
} |
} |
1503 |
|
if (!err && cons->attribute.intensity != DEFAULT_INTENSITY) |
1504 |
|
{ |
1505 |
|
if (attrp != attr) |
1506 |
|
*(attrp++) = ','; |
1507 |
|
switch (cons->attribute.intensity) |
1508 |
|
{ |
1509 |
|
case CONS_ATTR_INTENSITY_NORMAL: |
1510 |
|
attrp = stpcpy (attrp, "normal"); |
1511 |
|
break; |
1512 |
|
case CONS_ATTR_INTENSITY_BOLD: |
1513 |
|
attrp = stpcpy (attrp, "bold"); |
1514 |
|
break; |
1515 |
|
case CONS_ATTR_INTENSITY_DIM: |
1516 |
|
attrp = stpcpy (attrp, "dim"); |
1517 |
|
break; |
1518 |
|
} |
1519 |
|
} |
1520 |
|
if (!err && cons->attribute.underlined != DEFAULT_UNDERLINED) |
1521 |
|
{ |
1522 |
|
if (attrp != attr) |
1523 |
|
*(attrp++) = ','; |
1524 |
|
if (!cons->attribute.underlined) |
1525 |
|
attrp = stpcpy (attrp, "not-"); |
1526 |
|
attrp = stpcpy (attrp, "underlined"); |
1527 |
|
} |
1528 |
|
if (!err && cons->attribute.blinking != DEFAULT_BLINKING) |
1529 |
|
{ |
1530 |
|
if (attrp != attr) |
1531 |
|
*(attrp++) = ','; |
1532 |
|
if (!cons->attribute.blinking) |
1533 |
|
attrp = stpcpy (attrp, "not-"); |
1534 |
|
attrp = stpcpy (attrp, "blinking"); |
1535 |
|
} |
1536 |
|
if (!err && cons->attribute.reversed != DEFAULT_REVERSED) |
1537 |
|
{ |
1538 |
|
if (attrp != attr) |
1539 |
|
*(attrp++) = ','; |
1540 |
|
if (!cons->attribute.reversed) |
1541 |
|
attrp = stpcpy (attrp, "not-"); |
1542 |
|
attrp = stpcpy (attrp, "reversed"); |
1543 |
|
} |
1544 |
|
if (!err && cons->attribute.concealed != DEFAULT_CONCEALED) |
1545 |
|
{ |
1546 |
|
if (attrp != attr) |
1547 |
|
*(attrp++) = ','; |
1548 |
|
if (!cons->attribute.concealed) |
1549 |
|
attrp = stpcpy (attrp, "not-"); |
1550 |
|
attrp = stpcpy (attrp, "concealed"); |
1551 |
|
} |
1552 |
|
if (!err && attrp != attr) |
1553 |
|
err = argz_add (argz, argz_len, attr_str); |
1554 |
return err; |
return err; |
1555 |
} |
} |
1556 |
|
|
1891 |
error (1, ENOMEM, "Cannot create console structure"); |
error (1, ENOMEM, "Cannot create console structure"); |
1892 |
mutex_init (&cons->lock); |
mutex_init (&cons->lock); |
1893 |
cons->encoding = NULL; |
cons->encoding = NULL; |
1894 |
cons->foreground = DEFAULT_FOREGROUND; |
cons->attribute.intensity = DEFAULT_INTENSITY; |
1895 |
cons->background = DEFAULT_BACKGROUND; |
cons->attribute.underlined = DEFAULT_UNDERLINED; |
1896 |
|
cons->attribute.blinking = DEFAULT_BLINKING; |
1897 |
|
cons->attribute.reversed = DEFAULT_REVERSED; |
1898 |
|
cons->attribute.concealed = DEFAULT_CONCEALED; |
1899 |
|
cons->attribute.fgcol = DEFAULT_FOREGROUND; |
1900 |
|
cons->attribute.bgcol = DEFAULT_BACKGROUND; |
1901 |
cons->vcons_list = NULL; |
cons->vcons_list = NULL; |
1902 |
cons->dirmod_reqs = NULL; |
cons->dirmod_reqs = NULL; |
1903 |
cons->dirmod_tick = 0; |
cons->dirmod_tick = 0; |