console-server.c (021b91f045967d798528baba117ecf957c7838bd) console-server.c (6221ce9483f9431061223f635a4dbd82e44dc75b)
1/**
2 * Console server process for OpenBMC
3 *
4 * Copyright © 2016 IBM Corporation
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at

--- 57 unchanged lines hidden (view full) ---

66static const int n_internal_pollfds = 1;
67
68/* state shared with the signal handler */
69static bool sigint;
70
71static void usage(const char *progname)
72{
73 fprintf(stderr,
1/**
2 * Console server process for OpenBMC
3 *
4 * Copyright © 2016 IBM Corporation
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at

--- 57 unchanged lines hidden (view full) ---

66static const int n_internal_pollfds = 1;
67
68/* state shared with the signal handler */
69static bool sigint;
70
71static void usage(const char *progname)
72{
73 fprintf(stderr,
74"usage: %s [options]\n"
74"usage: %s [options] <DEVICE>\n"
75"\n"
76"Options:\n"
77" --config <FILE> Use FILE for configuration\n"
78"",
79 progname);
80}
81
82/* populates tty_dev and tty_sysfs_devnode, using the tty kernel name */

--- 128 unchanged lines hidden (view full) ---

211}
212
213static int tty_init(struct console *console, struct config *config)
214{
215 const char *val;
216 char *endp;
217 int rc;
218
75"\n"
76"Options:\n"
77" --config <FILE> Use FILE for configuration\n"
78"",
79 progname);
80}
81
82/* populates tty_dev and tty_sysfs_devnode, using the tty kernel name */

--- 128 unchanged lines hidden (view full) ---

211}
212
213static int tty_init(struct console *console, struct config *config)
214{
215 const char *val;
216 char *endp;
217 int rc;
218
219 console->tty_kname = config_get_value(config, "device");
220
221 val = config_get_value(config, "lpc-address");
222 if (val) {
223 console->tty_lpc_addr = strtoul(val, &endp, 0);
224 if (endp == optarg) {
225 warn("Invalid LPC address: '%s'", val);
226 return -1;
227 }
228 }

--- 270 unchanged lines hidden (view full) ---

499static const struct option options[] = {
500 { "config", required_argument, 0, 'c'},
501 { 0, 0, 0, 0},
502};
503
504int main(int argc, char **argv)
505{
506 const char *config_filename = NULL;
219 val = config_get_value(config, "lpc-address");
220 if (val) {
221 console->tty_lpc_addr = strtoul(val, &endp, 0);
222 if (endp == optarg) {
223 warn("Invalid LPC address: '%s'", val);
224 return -1;
225 }
226 }

--- 270 unchanged lines hidden (view full) ---

497static const struct option options[] = {
498 { "config", required_argument, 0, 'c'},
499 { 0, 0, 0, 0},
500};
501
502int main(int argc, char **argv)
503{
504 const char *config_filename = NULL;
505 const char *config_tty_kname = NULL;
507 struct console *console;
508 struct config *config;
509 int rc;
510
511 rc = -1;
512
513 for (;;) {
514 int c, idx;

--- 8 unchanged lines hidden (view full) ---

523 break;
524 case 'h':
525 case '?':
526 usage(argv[0]);
527 return EXIT_SUCCESS;
528 }
529 }
530
506 struct console *console;
507 struct config *config;
508 int rc;
509
510 rc = -1;
511
512 for (;;) {
513 int c, idx;

--- 8 unchanged lines hidden (view full) ---

522 break;
523 case 'h':
524 case '?':
525 usage(argv[0]);
526 return EXIT_SUCCESS;
527 }
528 }
529
530 if (optind >= argc) {
531 warnx("Required argument <DEVICE> missing");
532 usage(argv[0]);
533 return EXIT_FAILURE;
534 }
535
536 config_tty_kname = argv[optind];
537
531 console = malloc(sizeof(struct console));
532 memset(console, 0, sizeof(*console));
533 console->pollfds = calloc(n_internal_pollfds,
534 sizeof(*console->pollfds));
535
536 config = config_init(config_filename);
537 if (!config) {
538 warnx("Can't read configuration, exiting.");
539 goto out_free;
540 }
541
538 console = malloc(sizeof(struct console));
539 memset(console, 0, sizeof(*console));
540 console->pollfds = calloc(n_internal_pollfds,
541 sizeof(*console->pollfds));
542
543 config = config_init(config_filename);
544 if (!config) {
545 warnx("Can't read configuration, exiting.");
546 goto out_free;
547 }
548
549 console->tty_kname = config_tty_kname;
550
542 rc = tty_init(console, config);
543 if (rc)
544 goto out_config_fini;
545
546 handlers_init(console, config);
547
548 rc = run_console(console);
549

--- 14 unchanged lines hidden ---
551 rc = tty_init(console, config);
552 if (rc)
553 goto out_config_fini;
554
555 handlers_init(console, config);
556
557 rc = run_console(console);
558

--- 14 unchanged lines hidden ---