static enum request open_run_request(struct view *view, enum request request) { struct run_request *req = get_run_request(request); const char **argv = NULL; bool confirmed = FALSE; request = REQ_NONE; if (!req) { report("Unknown run request"); return request; } if (!argv_format(view->env, &argv, req->argv, FALSE, TRUE)) { report("Failed to format arguments"); return REQ_NONE; } if (req->flags.internal) { request = run_prompt_command(view, argv); } else { confirmed = !req->flags.confirm; if (req->flags.confirm) { char cmd[SIZEOF_STR], prompt[SIZEOF_STR]; const char *and_exit = req->flags.exit ? " and exit" : ""; if (argv_to_string(argv, cmd, sizeof(cmd), " ") && string_format(prompt, "Run `%s`%s?", cmd, and_exit) && prompt_yesno(prompt)) { confirmed = TRUE; } } if (confirmed && argv_remove_quotes(argv)) open_external_viewer(argv, NULL, req->flags.silent, !req->flags.exit, FALSE, ""); } if (argv) argv_free(argv); free(argv); if (request == REQ_NONE) { if (req->flags.confirm && !confirmed) request = REQ_NONE; else if (req->flags.exit) request = REQ_QUIT; else if (!req->flags.internal && watch_dirty(&view->watch)) request = REQ_REFRESH; } return request; }
/*********************************************************************** * * Function: cmd_maddr * * Purpose: Sets MAC address of ethernet device * * Processing: * See function. * * Parameters: None * * Outputs: None * * Returns: TRUE if the command was good, otherwise FALSE * * Notes: None * **********************************************************************/ BOOL_32 cmd_maddr(void) { int idx, offs; UNS_8 *p8, *curp, mac[8], str[16]; UNS_32 ea; BOOL_32 goodmac = FALSE; str [0] = '0'; str [1] = 'x'; str [4] = '\0'; mac [6] = mac [7] = 0; /* An address was passed, use it */ if (parse_get_entry_count() == 2) { curp = get_parsed_entry(1); goodmac = TRUE; offs = 0; for (idx = 0; idx < 6; idx++) { str [2] = curp[offs]; str [3] = curp[offs + 1]; goodmac &= str_hex_to_val(str, &ea); mac [idx] = (UNS_8) ea; offs += 3; } if (goodmac == TRUE) { /* Yes NO VERIFY? */ term_dat_out(smac_msg); if (prompt_yesno() != FALSE) { /* Save structure */ for (idx = 0; idx < 8; idx++) { phyhwdesc.mac [idx] = mac [idx]; } p8 = (UNS_8 *) &phyhwdesc; for (idx = 0; idx < sizeof(phyhwdesc); idx++) { phy3250_sspwrite(*p8, (PHY3250_SEEPROM_CFGOFS + idx)); p8++; } } } else { term_dat_out_crlf(macafail_msg); } } return goodmac; }
static enum request open_run_request(struct view *view, enum request request) { struct run_request *req = get_run_request(request); const char **argv = NULL; bool confirmed = FALSE; request = REQ_NONE; if (!req) { report("Unknown run request"); return request; } if (argv_format(view->env, &argv, req->argv, FALSE, TRUE)) { if (req->internal) { char cmd[SIZEOF_STR]; if (argv_to_string(argv, cmd, sizeof(cmd), " ")) { request = run_prompt_command(view, cmd); } } else { confirmed = !req->confirm; if (req->confirm) { char cmd[SIZEOF_STR], prompt[SIZEOF_STR]; const char *and_exit = req->exit ? " and exit" : ""; if (argv_to_string(argv, cmd, sizeof(cmd), " ") && string_format(prompt, "Run `%s`%s?", cmd, and_exit) && prompt_yesno(prompt)) { confirmed = TRUE; } } if (confirmed && argv_remove_quotes(argv)) { if (req->silent) io_run_bg(argv); else open_external_viewer(argv, NULL, !req->exit, ""); } } } if (argv) argv_free(argv); free(argv); if (request == REQ_NONE) { if (req->confirm && !confirmed) request = REQ_NONE; else if (req->exit) request = REQ_QUIT; else if (view_has_flags(view, VIEW_REFRESH) && !view->unrefreshable) request = REQ_REFRESH; } return request; }