struct device_handler {
struct discover_server *server;
+ int dry_run;
struct device **devices;
unsigned int n_devices;
return handlers[event->type][event->action](handler, event);
}
-struct device_handler *device_handler_init(struct discover_server *server)
+struct device_handler *device_handler_init(struct discover_server *server,
+ int dry_run)
{
struct device_handler *handler;
handler->devices = NULL;
handler->n_devices = 0;
handler->server = server;
+ handler->dry_run = dry_run;
list_init(&handler->contexts);
opt = find_boot_option_by_id(handler, cmd->option_id);
- boot(handler, opt, cmd, 0);
+ boot(handler, opt, cmd, handler->dry_run);
}
struct list_item list;
};
-struct device_handler *device_handler_init(struct discover_server *server);
+struct device_handler *device_handler_init(struct discover_server *server,
+ int dry_run);
void device_handler_destroy(struct device_handler *devices);
enum opt_value show_help;
const char *log_file;
enum opt_value show_version;
+ enum opt_value dry_run;
};
/**
static const struct option long_options[] = {
{"help", no_argument, NULL, 'h'},
{"log", required_argument, NULL, 'l'},
+ {"dry-run", no_argument, NULL, 'n'},
{"version", no_argument, NULL, 'V'},
{ NULL, 0, NULL, 0},
};
- static const char short_options[] = "hl:V";
+ static const char short_options[] = "hl:nV";
static const struct opts default_values = {
.log_file = "/var/log/petitboot/pb-discover.log",
+ .dry_run = opt_no,
};
*opts = default_values;
case 'l':
opts->log_file = optarg;
break;
+ case 'n':
+ opts->dry_run = opt_yes;
+ break;
case 'V':
opts->show_version = opt_yes;
break;
if (!server)
return EXIT_FAILURE;
- handler = device_handler_init(server);
+ handler = device_handler_init(server, opts.dry_run == opt_yes);
if (!handler)
return EXIT_FAILURE;
{
print_version();
printf(
-"Usage: petitboot-nc [-d, --dry-run] [-h, --help] [-l, --log log-file]\n"
+"Usage: petitboot-nc [-h, --help] [-l, --log log-file]\n"
" [-s, --start-daemon] [-V, --version]\n");
}
*/
struct opts {
- enum opt_value dry_run;
enum opt_value show_help;
const char *log_file;
enum opt_value start_daemon;
static int opts_parse(struct opts *opts, int argc, char *argv[])
{
static const struct option long_options[] = {
- {"dry-run", no_argument, NULL, 'd'},
{"help", no_argument, NULL, 'h'},
{"log", required_argument, NULL, 'l'},
{"start-daemon", no_argument, NULL, 's'},
break;
switch (c) {
- case 'd':
- opts->dry_run = opt_yes;
- break;
case 'h':
opts->show_help = opt_yes;
break;
m->on_open = cui_on_open;
m->scr.frame.title = talloc_asprintf(m,
- "Petitboot (" PACKAGE_VERSION ")%s",
- (pb_cui->cui->dry_run ? " (dry-run)" : ""));
+ "Petitboot (" PACKAGE_VERSION ")");
m->scr.frame.help = talloc_strdup(m,
"ESC=exit, Enter=accept, e=edit, o=open");
m->scr.frame.status = talloc_strdup(m, "Welcome to Petitboot");
return EXIT_FAILURE;
}
- pb.cui = cui_init(&pb, NULL, opts.start_daemon, opts.dry_run);
+ pb.cui = cui_init(&pb, NULL, opts.start_daemon);
if (!pb.cui)
return EXIT_FAILURE;
*/
struct cui *cui_init(void* platform_info,
- int (*js_map)(const struct js_event *e), int start_deamon, int dry_run)
+ int (*js_map)(const struct js_event *e), int start_deamon)
{
struct cui *cui;
unsigned int i;
cui->c_sig = pb_cui_sig;
cui->platform_info = platform_info;
cui->timer.handle_timeout = cui_handle_timeout;
- cui->dry_run = dry_run;
cui->waitset = waitset_create(cui);
/* Loop here for scripts that just started the server. */
enum pb_nc_sig c_sig;
sig_atomic_t abort;
sig_atomic_t resize;
- int dry_run;
struct nc_scr *current;
struct pmenu *main;
struct ui_timer timer;
};
struct cui *cui_init(void* platform_info,
- int (*js_map)(const struct js_event *e), int start_deamon, int dry_run);
+ int (*js_map)(const struct js_event *e), int start_deamon);
struct nc_scr *cui_set_current(struct cui *cui, struct nc_scr *scr);
int cui_run(struct cui *cui, struct pmenu *main, unsigned int default_item);
int cui_boot_editor_run(struct pmenu_item *item);
return EXIT_FAILURE;
}
- client = pbt_client_init(opts.backend, 1024, 640,
- opts.start_daemon, opts.dry_run);
+ client = pbt_client_init(opts.backend, 1024, 640, opts.start_daemon);
if (!client) {
ui_result = EXIT_FAILURE;
}
struct pbt_client *pbt_client_init(enum pbt_twin_backend backend,
- unsigned int width, unsigned int height,
- int start_deamon, int dry_run)
+ unsigned int width, unsigned int height, int start_deamon)
{
struct pbt_client *pbt_client;
unsigned int i;
pbt_client->waitset = waitset_create(pbt_client);
pbt_client->sig = "pbt_client";
- pbt_client->dry_run = dry_run;
pbt_client->frame.scr = pbt_scr_init(pbt_client, pbt_client->waitset,
backend, width, height, NULL, NULL);
struct pbt_client {
const char *sig;
- int dry_run;
struct pb_signal_data signal_data;
void *client_data;
struct pbt_frame frame;
};
struct pbt_client *pbt_client_init(enum pbt_twin_backend backend,
- unsigned int width, unsigned int height,
- int start_deamon, int dry_run);
+ unsigned int width, unsigned int height, int start_deamon);
void pbt_client_destroy(struct pbt_client *client);
void pbt_client_resize(struct pbt_client *client);
{
pbt_print_version();
printf(
-"Usage: petitboot-twin [-d, --dry-run] [-h, --help] [-l, --log log-file]\n"
+"Usage: petitboot-twin [-h, --help] [-l, --log log-file]\n"
" [-r, --reset-defaults] [-s, --start-daemon]\n"
" [-t, --timeout] [-V, --version]\n"
" [[-f --fbdev] | [-x --x11]]\n");
int pbt_opts_parse(struct pbt_opts *opts, int argc, char *argv[])
{
static const struct option long_options[] = {
- {"dry-run", no_argument, NULL, 'd'},
{"fbdev", no_argument, NULL, 'f'},
{"help", no_argument, NULL, 'h'},
{"log", required_argument, NULL, 'l'},
break;
switch (c) {
- case 'd':
- opts->dry_run = pbt_opt_yes;
- break;
case 'f':
opts->backend = pbt_twin_fbdev;
break;
struct pbt_opts {
enum pbt_twin_backend backend;
- enum pbt_opt_value dry_run;
enum pbt_opt_value show_help;
const char *log_file;
enum pbt_opt_value reset_defaults;