void keymap_actuate(const uint8_t row, const uint8_t col, const int16_t idle_time) { #ifdef SIMPLE_DEVICE const uint8_t code = getmap(row,col); #else const uint8_t code = translate_code(getmap(row,col)); #endif /* SIMPLE_DEVICE */ const uint8_t action = getaction(row,col); const uint8_t tapkey = gettapkey(row,col); #ifdef KEYMAP_MEMORY_SAVE g_matrixlayer[row][col] = g_layer_select; #else g_matrixcode[row][col] = code; g_matrixaction[row][col] = action; g_matrixtapkey[row][col] = tapkey; #endif /* KEYMAP_MEMORY_SAVE */ doubletap_down(row,col,idle_time); handle_code_actuate(code, action, tapkey); #ifdef MAX_NUMBER_OF_BACKLIGHTS backlight_react(); #endif /* MAX_NUMBER_OF_BACKLIGHTS */ USB_wakeup(); }
// --------------------------------------------------------------------- void ToolBar::setbutton(string p, QStringList opt) { bool n=true; if (opt.isEmpty()) { error("set toolbar requires button_id: " + p); return; } else if (1<opt.size()) n=!!c_strtoi(q2s(opt.at(1))); QString btnid= opt.at(0); QAction * a=getaction(btnid); if (!a) { error("set toolbar cannot find button_id: " + p + " " + q2s(btnid)); return; } if (p=="checkable") a->setCheckable(n); else if (p=="checked") a->setChecked(n); else if (p=="enable") a->setEnabled(n); else { error("set toolbar attribute error: " + p); return; } }
/* main functions. */ int main(int argc, char **argv) { register int c; /* getopt varbs */ extern char *optarg; char *optstring = NULL; int path_index, err = 0; int cmd = 0; /* Cmd verb from cmd line */ int exit_code = 0; /* exit code for program */ int temp_fd; /* For -f option */ char *file_name = NULL; int option_t_input; char *path_phys = NULL; int USE_FCHBA = 0; whoami = argv[0]; /* * Enable locale announcement */ i18n_catopen(); while ((c = getopt(argc, argv, "ve")) != EOF) { switch (c) { case 'v': Options |= PVERBOSE; break; case 'e': Options |= EXPERT; break; default: /* Note: getopt prints an error if invalid option */ USEAGE() exit(-1); } /* End of switch(c) */ } setbuf(stdout, NULL); /* set stdout unbuffered. */ /* * Build any i18n global variables */ dtype[0] = MSGSTR(2192, "Disk device"); dtype[1] = MSGSTR(2193, "Tape device"); dtype[2] = MSGSTR(2194, "Printer device"); dtype[3] = MSGSTR(2195, "Processor device"); dtype[4] = MSGSTR(2196, "WORM device"); dtype[5] = MSGSTR(2197, "CD-ROM device"); dtype[6] = MSGSTR(2198, "Scanner device"); dtype[7] = MSGSTR(2199, "Optical memory device"); dtype[8] = MSGSTR(2200, "Medium changer device"); dtype[9] = MSGSTR(2201, "Communications device"); dtype[10] = MSGSTR(107, "Graphic arts device"); dtype[11] = MSGSTR(107, "Graphic arts device"); dtype[12] = MSGSTR(2202, "Array controller device"); dtype[13] = MSGSTR(2203, "SES device"); dtype[14] = MSGSTR(71, "Reserved"); dtype[15] = MSGSTR(71, "Reserved"); /* * Get subcommand. */ if ((getaction(argv[optind], Keywords, &cmd)) == EOK) { optind++; if ((cmd != PROBE) && (cmd != FCAL_UPDATE) && (cmd != QLGC_UPDATE) && (cmd != FCODE_UPDATE) && (cmd != INSERT_DEVICE) && (cmd != SYSDUMP) && (cmd != AU) && (cmd != PORT) && (cmd != CREATE_FAB) && (optind >= argc)) { (void) fprintf(stderr, MSGSTR(2204, "Error: enclosure or pathname not specified.\n")); USEAGE(); exit(-1); } } else { (void) fprintf(stderr, MSGSTR(2205, "%s: subcommand not specified.\n"), whoami); USEAGE(); exit(-1); } /* Extract & Save subcommand options */ if ((cmd == ENABLE) || (cmd == BYPASS)) { optstring = "Ffrab"; } else if (cmd == FCODE_UPDATE) { optstring = "pd:"; } else if (cmd == REMOVE_DEVICE) { optstring = "F"; } else if (cmd == CREATE_FAB) { optstring = "f:"; } else { optstring = "Fryszabepcdlvt:f:w:"; } while ((c = getopt(argc, argv, optstring)) != EOF) { switch (c) { case 'a': Options |= OPTION_A; break; case 'b': Options |= OPTION_B; break; case 'c': Options |= OPTION_C; break; case 'd': Options |= OPTION_D; if (cmd == FCODE_UPDATE) { file_name = optarg; } break; case 'e': Options |= OPTION_E; break; case 'f': Options |= OPTION_F; if (!((cmd == ENABLE) || (cmd == BYPASS))) { file_name = optarg; } break; case 'F': Options |= OPTION_CAPF; break; case 'l': Options |= OPTION_L; break; case 'p': Options |= OPTION_P; break; case 'r': Options |= OPTION_R; break; case 's': Options |= SAVE; break; case 't': Options |= OPTION_T; option_t_input = atoi(optarg); break; case 'v': Options |= OPTION_V; break; case 'z': Options |= OPTION_Z; break; case 'y': Options |= OPTION_Y; break; default: /* Note: getopt prints an error if invalid option */ USEAGE() exit(-1); } /* End of switch(c) */ } if ((cmd != PROBE) && (cmd != FCAL_UPDATE) && (cmd != QLGC_UPDATE) && (cmd != FCODE_UPDATE) && (cmd != INSERT_DEVICE) && (cmd != SYSDUMP) && (cmd != AU) && (cmd != PORT) && (cmd != CREATE_FAB) && (optind >= argc)) { (void) fprintf(stderr, MSGSTR(2206, "Error: enclosure or pathname not specified.\n")); USEAGE(); exit(-1); } path_index = optind; /* * Check if the file supplied with the -f option is valid * Some sub commands (bypass for example) use the -f option * for other reasons. In such cases, "file_name" should be * NULL. */ if ((file_name != NULL) && (Options & OPTION_F)) { if ((temp_fd = open(file_name, O_RDONLY)) == -1) { perror(file_name); exit(-1); } else { close(temp_fd); } } /* Determine which mode to operate in (FC-HBA or original) */ USE_FCHBA = use_fchba(); switch (cmd) { case DISPLAY: if (Options & ~(PVERBOSE | OPTION_A | OPTION_Z | OPTION_R | OPTION_P | OPTION_V | OPTION_L | OPTION_E | OPTION_T)) { USEAGE(); exit(-1); } /* Display object(s) */ if (USE_FCHBA) { exit_code = fchba_display_config(&argv[path_index], option_t_input, argc - path_index); } else { exit_code = adm_display_config(&argv[path_index]); } break; case DOWNLOAD: if (Options & ~(PVERBOSE | OPTION_F | SAVE)) { USEAGE(); exit(-1); } adm_download(&argv[path_index], file_name); break; case ENCLOSURE_NAMES: if (Options & ~PVERBOSE) { USEAGE(); exit(-1); } up_encl_name(&argv[path_index], argc); break; case FAILOVER: if (Options & ~PVERBOSE) { USEAGE(); exit(-1); } adm_failover(&argv[path_index]); break; case INQUIRY: if (Options & ~(PVERBOSE)) { USEAGE(); exit(-1); } if (USE_FCHBA) { exit_code = fchba_inquiry(&argv[path_index]); } else { exit_code = adm_inquiry(&argv[path_index]); } break; case PROBE: if (Options & ~(PVERBOSE | OPTION_P)) { USEAGE(); exit(-1); } /* * A special check just in case someone entered * any characters after the -p or the probe. * * (I know, a nit.) */ if (((Options & PVERBOSE) && (Options & OPTION_P) && (argc != 4)) || (!(Options & PVERBOSE) && (Options & OPTION_P) && (argc != 3)) || ((Options & PVERBOSE) && (!(Options & OPTION_P)) && (argc != 3)) || (!(Options & PVERBOSE) && (!(Options & OPTION_P)) && (argc != 2))) { (void) fprintf(stderr, MSGSTR(114, "Error: Incorrect number of arguments.\n")); (void) fprintf(stderr, MSGSTR(2208, "Usage: %s [-v] subcommand [option]\n"), whoami); exit(-1); } if (USE_FCHBA) { exit_code = fchba_non_encl_probe(); } else { pho_probe(); non_encl_probe(); } break; case FCODE_UPDATE: /* Update Fcode in all cards */ if ((Options & ~(PVERBOSE)) & ~(OPTION_P | OPTION_D) || argv[path_index]) { USEAGE(); exit(-1); } if (!((Options & (OPTION_P | OPTION_D)) && !((Options & OPTION_P) && (Options & OPTION_D)))) { USEAGE(); exit(-1); } if (adm_fcode(Options & PVERBOSE, file_name) != 0) { exit(-1); } break; case QLGC_UPDATE: /* Update Fcode in PCI HBA card(s) */ if ((Options & ~(PVERBOSE)) & ~(OPTION_F) || argv[path_index]) { USEAGE(); exit(-1); } if (q_qlgc_update(Options & PVERBOSE, file_name) != 0) { exit(-1); } break; case FCAL_UPDATE: /* Update Fcode in Sbus soc+ card */ if ((Options & ~(PVERBOSE)) & ~(OPTION_F) || argv[path_index]) { USEAGE(); exit(-1); } exit_code = fcal_update(Options & PVERBOSE, file_name); break; case SET_BOOT_DEV: /* Set boot-device variable in nvram */ exit_code = setboot(Options & OPTION_Y, Options & PVERBOSE, argv[path_index]); break; case LED: if (Options & ~(PVERBOSE)) { USEAGE(); exit(-1); } adm_led(&argv[path_index], L_LED_STATUS); break; case LED_ON: if (Options & ~(PVERBOSE)) { USEAGE(); exit(-1); } adm_led(&argv[path_index], L_LED_ON); break; case LED_OFF: if (Options & ~(PVERBOSE)) { USEAGE(); exit(-1); } adm_led(&argv[path_index], L_LED_OFF); break; case LED_BLINK: if (Options & ~(PVERBOSE)) { USEAGE(); exit(-1); } adm_led(&argv[path_index], L_LED_RQST_IDENTIFY); break; case PASSWORD: if (Options & ~(PVERBOSE)) { USEAGE(); exit(-1); } up_password(&argv[path_index]); break; case RESERVE: if (Options & (~PVERBOSE)) { USEAGE(); exit(-1); } VERBPRINT(MSGSTR(2209, " Reserving: \n %s\n"), argv[path_index]); if (USE_FCHBA) { struct stat sbuf; /* Just stat the argument and make sure it exists */ if (stat(argv[path_index], &sbuf) < 0) { (void) fprintf(stderr, "%s: ", whoami); (void) fprintf(stderr, MSGSTR(112, "Error: Invalid pathname (%s)"), argv[path_index]); (void) fprintf(stderr, "\n"); exit(-1); } path_phys = argv[path_index]; if (err = scsi_reserve(path_phys)) { (void) print_errString(err, argv[path_index]); exit(-1); } } else { exit_code = adm_reserve(argv[path_index]); } break; case RELEASE: if (Options & (~PVERBOSE)) { USEAGE(); exit(-1); } VERBPRINT(MSGSTR(2210, " Canceling Reservation for:\n %s\n"), argv[path_index]); if (USE_FCHBA) { struct stat sbuf; /* Just stat the argument and make sure it exists */ if (stat(argv[path_index], &sbuf) < 0) { (void) fprintf(stderr, "%s: ", whoami); (void) fprintf(stderr, MSGSTR(112, "Error: Invalid pathname (%s)"), argv[path_index]); (void) fprintf(stderr, "\n"); exit(-1); } path_phys = argv[path_index]; if (err = scsi_release(path_phys)) { (void) print_errString(err, argv[path_index]); exit(-1); } } else { exit_code = adm_release(argv[path_index]); } break; case START: if (Options & ~(PVERBOSE)) { USEAGE(); exit(-1); } exit_code = adm_start(&argv[path_index]); break; case STOP: if (Options & ~(PVERBOSE)) { USEAGE(); exit(-1); } exit_code = adm_stop(&argv[path_index]); break; case POWER_OFF: if (Options & ~(PVERBOSE | OPTION_CAPF)) { USEAGE(); exit(-1); } exit_code = adm_power_off(&argv[path_index], 1); break; case POWER_ON: if (Options & (~PVERBOSE)) { USEAGE(); exit(-1); } exit_code = adm_power_off(&argv[path_index], 0); break; /* * EXPERT commands. */ case FORCELIP: if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) { E_USEAGE(); exit(-1); } exit_code = adm_forcelip(&argv[path_index]); break; case BYPASS: if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT | OPTION_CAPF | OPTION_A | OPTION_B | OPTION_F | OPTION_R)) || !(Options & (OPTION_A | OPTION_B)) || ((Options & OPTION_A) && (Options & OPTION_B))) { E_USEAGE(); exit(-1); } adm_bypass_enable(&argv[path_index], 1); break; case ENABLE: if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT | OPTION_CAPF | OPTION_A | OPTION_B | OPTION_F | OPTION_R)) || !(Options & (OPTION_A | OPTION_B)) || ((Options & OPTION_A) && (Options & OPTION_B))) { E_USEAGE(); exit(-1); } adm_bypass_enable(&argv[path_index], 0); break; case LUX_P_OFFLINE: /* Offline a port */ if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) { E_USEAGE(); exit(-1); } exit_code = adm_port_offline_online(&argv[path_index], LUX_P_OFFLINE); break; case LUX_P_ONLINE: /* Online a port */ if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) { E_USEAGE(); exit(-1); } exit_code = adm_port_offline_online(&argv[path_index], LUX_P_ONLINE); break; case RDLS: if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) { E_USEAGE(); exit(-1); } if (USE_FCHBA) { exit_code = fchba_display_link_status(&argv[path_index]); } else { display_link_status(&argv[path_index]); } break; case CREATE_FAB: if (!(Options & (EXPERT | OPTION_F)) || (Options & ~(PVERBOSE | EXPERT | OPTION_F))) { E_USEAGE(); exit(-1); } if (read_repos_file(file_name) != 0) { exit(-1); } break; /* * Undocumented commands. */ case CHECK_FILE: /* Undocumented Cmd */ if (Options & ~(PVERBOSE)) { USEAGE(); exit(-1); } exit_code = adm_check_file(&argv[path_index], (Options & PVERBOSE)); break; case DUMP: /* Undocumented Cmd */ if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) { USEAGE(); exit(-1); } dump(&argv[path_index]); break; case DUMP_MAP: /* Undocumented Cmd */ if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) { USEAGE(); exit(-1); } if (USE_FCHBA) { exit_code = fchba_dump_map(&argv[path_index]); } else { dump_map(&argv[path_index]); } break; case SYSDUMP: if (Options & ~(PVERBOSE)) { USEAGE(); exit(-1); } if (err = sysdump(Options & PVERBOSE)) { (void) print_errString(err, NULL); exit(-1); } break; case PORT: /* Undocumented command */ if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) { USEAGE(); exit(-1); } if (USE_FCHBA) { exit_code = fchba_display_port(Options & PVERBOSE); } else { exit_code = adm_display_port(Options & PVERBOSE); } break; case EXT_LOOPBACK: if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) { USEAGE(); exit(-1); } if (adm_port_loopback(argv[path_index], EXT_LOOPBACK) < 0) { exit(-1); } break; case INT_LOOPBACK: if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) { USEAGE(); exit(-1); } if (adm_port_loopback(argv[path_index], INT_LOOPBACK) < 0) { exit(-1); } break; case NO_LOOPBACK: if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) { USEAGE(); exit(-1); } if (adm_port_loopback(argv[path_index], NO_LOOPBACK) < 0) { exit(-1); } break; case VERSION: break; case INSERT_DEVICE: if (argv[path_index] == NULL) { if ((err = h_insertSena_fcdev()) != 0) { (void) print_errString(err, NULL); exit(-1); } } else if ((err = hotplug(INSERT_DEVICE, &argv[path_index], Options & PVERBOSE, Options & OPTION_CAPF)) != 0) { (void) print_errString(err, argv[path_index]); exit(-1); } break; case REMOVE_DEVICE: if (err = hotplug(REMOVE_DEVICE, &argv[path_index], Options & PVERBOSE, Options & OPTION_CAPF)) { (void) print_errString(err, argv[path_index]); exit(-1); } break; /* for hotplug device operations */ case DEV_ONLINE: case DEV_OFFLINE: case DEV_GETSTATE: case DEV_RESET: case BUS_QUIESCE: case BUS_UNQUIESCE: case BUS_GETSTATE: case BUS_RESET: case BUS_RESETALL: if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) { E_USEAGE(); exit(-1); } if (USE_FCHBA) { if (fchba_hotplug_e(cmd, &argv[path_index], Options & PVERBOSE, Options & OPTION_CAPF) != 0) { exit(-1); } } else { if (hotplug_e(cmd, &argv[path_index], Options & PVERBOSE, Options & OPTION_CAPF) != 0) { exit(-1); } } break; default: (void) fprintf(stderr, MSGSTR(2213, "%s: subcommand decode failed.\n"), whoami); USEAGE(); exit(-1); } return (exit_code); }