int main(void) { struct nfct_labelmap *l; l = nfct_labelmap_new("/"); assert(l == NULL); l = nfct_labelmap_new(NULL); if (l) { puts("default connlabel.conf:"); dump_map(l); nfct_labelmap_destroy(l); } else { puts("no default config found"); } l = nfct_labelmap_new("qa-connlabel.conf"); if (!l) l = nfct_labelmap_new("qa/qa-connlabel.conf"); assert(l); puts("qa-connlabel.conf:"); dump_map(l); print_label(l); nfct_labelmap_destroy(l); return 0; }
int main(int argc, char *argv[]) { tmx_map *m; if (argc != 2) { fprintf(stderr, "usage: %s <map.tmx>\n", argv[0]); return EXIT_FAILURE; } tmx_alloc_func = dbg_alloc; /* alloc/free dbg */ tmx_free_func = dbg_free; m = tmx_load(argv[1]); if (!m) tmx_perror("error"); dump_map(m); tmx_map_free(m); printf("\n%d mem alloc not freed\n", mal_vs_free_count); #ifdef PAUSE puts("press <Enter> to quit\n"); getchar(); #endif return EXIT_SUCCESS; }
/** Send a server map to a client. * @param[in] cptr Client to who to send the map. * @param[in] server Top-level server to display. * @param[in] mask Mask to filter which servers are shown. * @param[in] prompt_length Number of characters used in prompt. */ static void dump_map(struct Client *cptr, struct Client *server, char *mask, int prompt_length) { const char *chr; static char prompt[64]; struct DLink *lp; char *p = prompt + prompt_length; int cnt = 0; *p = '\0'; if (prompt_length > 60) send_reply(cptr, RPL_MAPMORE, prompt, cli_name(server)); else { char lag[512]; if (cli_serv(server)->lag>10000) lag[0]=0; else if (cli_serv(server)->lag<0) strcpy(lag,"(0s)"); else sprintf(lag,"(%is)",cli_serv(server)->lag); if (IsBurst(server)) chr = "*"; else if (IsBurstAck(server)) chr = "!"; else chr = ""; send_reply(cptr, RPL_MAP, prompt, chr, cli_name(server), lag, (server == &me) ? UserStats.local_clients : cli_serv(server)->clients); } if (prompt_length > 0) { p[-1] = ' '; if (p[-2] == '`') p[-2] = ' '; } if (prompt_length > 60) return; strcpy(p, "|-"); for (lp = cli_serv(server)->down; lp; lp = lp->next) if (match(mask, cli_name(lp->value.cptr))) ClrFlag(lp->value.cptr, FLAG_MAP); else { SetFlag(lp->value.cptr, FLAG_MAP); cnt++; } for (lp = cli_serv(server)->down; lp; lp = lp->next) { if (!HasFlag(lp->value.cptr, FLAG_MAP)) continue; if (--cnt == 0) *p = '`'; dump_map(cptr, lp->value.cptr, mask, prompt_length + 2); } if (prompt_length > 0) p[-1] = '-'; }
int on_mmap(char *v, void *k) { CArgs args; int i; parse_arg_ex(v, &args, FS); if(args.argc == 1){ for(i=0; i<KERN_NUM_SECTIONS; i++){ utils_trace("Dump of memory section %d\n", i); dump_map(i); } }else{ for(i=1; i<args.argc; i++){ dump_map(atoi(args.argv[i])); } } return F8_SUCCESS; }
/* * m_map - generic message handler * -- by Run * * parv[0] = sender prefix * parv[1] = server mask */ int m_map(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { if (feature_bool(FEAT_HIS_MAP) && !IsAnOper(sptr)) { sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :%s %s", sptr, "/MAP has been disabled; visit", feature_str(FEAT_HIS_URLSERVERS)); return 0; } if (parc < 2) parv[1] = "*"; dump_map(sptr, &me, parv[1], 0); send_reply(sptr, RPL_MAPEND); return 0; }
void PathPlanner::plan_path(FrameObject * obj) { // XXX this is stupid and slow, but should work well enough FrameObject::PathAgent & agent = *obj->agent; agent.nodes.clear(); PathPlanner * planner = (PathPlanner*)agent.planner; if (agent.x == agent.dest_x && agent.y == agent.dest_y) return; int grid_x = clamp(agent.dest_x, 0, planner->map_width - 1); int grid_y = clamp(agent.dest_y, 0, planner->map_height - 1); int test = planner->to_index(grid_x, grid_y); if (planner->map.get(test)) { #ifndef NDEBUG dump_map(grid_x, grid_y, planner); #endif std::cout << "Destination not possible" << std::endl; return; } Grid grid(*planner, agent); unsigned step = 1; JPS::PathVector path; bool found = JPS::findPath(path, grid, agent.x, agent.y, agent.dest_x, agent.dest_y, step); if (!found) { std::cout << "No path found" << std::endl; return; } JPS::PathVector::iterator it; for (int i = 0; i < int(path.size()); ++i) { JPS::Position & node = path[i]; PathNode n = {node.x, node.y}; agent.nodes.push_back(n); } }
// Report on final memory locations. void e820_prepboot(void) { dump_map(); }
// Report on final memory locations. void memmap_finalize(void) { dump_map(); }
int main(int argc, char **argv) { int c = 0; //Temp varliable to hold our character for the switch int cflag = 0, aflag = 0, dflag = 0; int err = 0; char *avalue = NULL; if (argc < 2) { print_usage(); err = -EINVAL; goto out; } while ((c = getopt(argc, argv, "a:cd")) != -1) { switch (c) { case 'c': cflag = c; break; case 'a': aflag = 1; avalue = (char *)malloc(strlen(optarg) + 1); strcpy(avalue, optarg); break; case 'd': dflag++; break; case '?': if (isprint(optopt)) fprintf(stderr, "Unknown option `-%c'.\n", optopt); else fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt); print_usage(); err = -EINVAL; goto out; break; default: print_usage(); err = -EINVAL; goto out; break; } } if (optind == argc) { print_usage(); err = -EINVAL; goto out; } if (!(cflag ^ aflag ^ dflag)) { print_usage(); err = -EINVAL; goto out; } if (cflag) { err = create_forwardmap(argv[optind]); if (err) { unlink(argv[optind]); } goto out; } else if (aflag) { if (optind + 1 > argc) { print_usage(); err = -EINVAL; goto out; } err = create_reversemap(argv[optind], argv[optind + 1], avalue); if (err) { unlink(argv[optind]); goto out; } } else if (dflag) { err = dump_map(argv[optind], dflag); if (err) { goto out; } } out: if (avalue) { free(avalue); } return err; }
int main (int argc, char *argv[]) { int i; char *groupname = NULL; char *membername = NULL; ToolAction action = DUMPMAPS; char *configdir = NULL; char *objtype = NULL; OSyncError *error = NULL; OSyncGroupEnv *env = NULL; if (argc == 1) usage (argv[0], 1); groupname = argv[1]; for (i = 2; i < argc; i++) { char *arg = argv[i]; if (!strcmp (arg, "--mappings")) { action = DUMPMAPS; objtype = argv[i + 1]; i++; if (!objtype) usage (argv[0], 1); } else if (!strcmp (arg, "--hash")) { action = DUMPHASH; objtype = argv[i + 1]; membername = argv[i + 2]; i += 2; if (!objtype || !membername) usage (argv[0], 1); } else if (!strcmp (arg, "--reset")) { action = RESET; } else if (!strcmp (arg, "--help")) { usage (argv[0], 0); } else if (!strcmp (arg, "--configdir")) { configdir = argv[i + 1]; i++; if (!configdir) usage (argv[0], 1); } else if (!strcmp (arg, "--")) { break; } else if (arg[0] == '-') { usage (argv[0], 1); } else { usage (argv[0], 1); } } env = osync_group_env_new(&error); if (!env) goto error; if (!osync_group_env_load_groups(env, configdir, &error)) goto error; switch (action) { case DUMPMAPS: if (objtype) dump_map_objtype(env, objtype, groupname); else dump_map(env, groupname); break; case DUMPHASH: dump_hash(env, objtype, groupname, membername); break; case RESET: reset(env, groupname); break; } osync_group_env_unref(env); return 0; error: if (env) osync_group_env_unref(env); printf("ERROR: %s", osync_error_print(&error)); osync_error_unref(&error); return 1; }
static void dump_map(struct Client *cptr, struct Client *server, char *mask, int prompt_length) { static char prompt[64]; struct DLink *lp; char *p = &prompt[prompt_length]; int cnt = 0; *p = '\0'; if (prompt_length > 60) send_reply(cptr, RPL_MAPMORE, prompt, cli_name(server)); else { char lag[512]; int showserv = 1; unsigned int totalusers = UserStats.clients; unsigned int percentage; unsigned int serv_clients; if (totalusers == 0) totalusers = 1; /* ¿? NO deberia ocurrir nunca... */ percentage = (10000 * (IsMe(server) ? UserStats.local_clients : cli_serv(server)->clients)) / totalusers; if (IsMe(server)) strcpy(lag,"(0s)"); else if (cli_serv(server)->lag>10000) lag[0]=0; else if (cli_serv(server)->lag<0) strcpy(lag,"(0s)"); else sprintf(lag,"(%is)",cli_serv(server)->lag); if (IsHiddenserv(server) && !feature_bool(FEAT_SHOWSERVON_MAP)) if (!IsAnOper(cptr) && !es_representante(cptr)) showserv = 0; serv_clients = (server == &me) ? UserStats.local_clients : cli_serv(server)->clients; send_reply(cptr, RPL_MAP, prompt, ( (IsBurst(server)) ? "*" : (IsBurstAck(server) ? "!" : "")), showserv ? cli_name(server) : feature_str(FEAT_HIS_SERVERNAME), lag, NumServ(server), base64toint(NumServ(server)), serv_clients, (serv_clients == 1) ? "" : "s", (percentage / 100), (percentage % 100)); } if (prompt_length > 0) { p[-1] = ' '; if (p[-2] == '`') p[-2] = ' '; } if (prompt_length > 60) return; strcpy(p, "|-"); for (lp = cli_serv(server)->down; lp; lp = lp->next) if (match(mask, cli_name(lp->value.cptr))) cli_flags(lp->value.cptr) &= ~FLAGS_MAP; else { cli_flags(lp->value.cptr) |= FLAGS_MAP; cnt++; } for (lp = cli_serv(server)->down; lp; lp = lp->next) { if ((cli_flags(lp->value.cptr) & FLAGS_MAP) == 0) continue; if (--cnt == 0) *p = '`'; dump_map(cptr, lp->value.cptr, mask, prompt_length + 2); } if (prompt_length > 0) p[-1] = '-'; }
/* 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); }
/*! Save a keymap as C source file - this is used to get the default keymap into the input_server, for example. \a mapName is usually the path of the input keymap, and is used as the name of the keymap (the path will be removed, as well as its suffix). */ status_t Keymap::SaveAsCppHeader(const char* fileName, const char* mapName) { BString name = mapName; // cut off path int32 index = name.FindLast('/'); if (index > 0) name.Remove(0, index + 1); // prune ".keymap" index = name.FindLast('.'); if (index > 0) name.Truncate(index); FILE* file = fopen(fileName, "w"); if (file == NULL) return errno; fprintf(file, "/*\n" " * Haiku Keymap\n" " * This file is generated automatically. Don't edit!\n" " */\n\n"); fprintf(file, "#include <InterfaceDefs.h>\n\n"); fprintf(file, "const char *kSystemKeymapName = \"%s\";\n\n", name.String()); fprintf(file, "const key_map kSystemKeymap = {\n"); fprintf(file, "\tversion:%" B_PRIu32 ",\n", fKeys.version); fprintf(file, "\tcaps_key:0x%" B_PRIx32 ",\n", fKeys.caps_key); fprintf(file, "\tscroll_key:0x%" B_PRIx32 ",\n", fKeys.scroll_key); fprintf(file, "\tnum_key:0x%" B_PRIx32 ",\n", fKeys.num_key); fprintf(file, "\tleft_shift_key:0x%" B_PRIx32 ",\n", fKeys.left_shift_key); fprintf(file, "\tright_shift_key:0x%" B_PRIx32 ",\n", fKeys.right_shift_key); fprintf(file, "\tleft_command_key:0x%" B_PRIx32 ",\n", fKeys.left_command_key); fprintf(file, "\tright_command_key:0x%" B_PRIx32 ",\n", fKeys.right_command_key); fprintf(file, "\tleft_control_key:0x%" B_PRIx32 ",\n", fKeys.left_control_key); fprintf(file, "\tright_control_key:0x%" B_PRIx32 ",\n", fKeys.right_control_key); fprintf(file, "\tleft_option_key:0x%" B_PRIx32 ",\n", fKeys.left_option_key); fprintf(file, "\tright_option_key:0x%" B_PRIx32 ",\n", fKeys.right_option_key); fprintf(file, "\tmenu_key:0x%" B_PRIx32 ",\n", fKeys.menu_key); fprintf(file, "\tlock_settings:0x%" B_PRIx32 ",\n", fKeys.lock_settings); dump_map(file, "control_map", fKeys.control_map); dump_map(file, "option_caps_shift_map", fKeys.option_caps_shift_map); dump_map(file, "option_caps_map", fKeys.option_caps_map); dump_map(file, "option_shift_map", fKeys.option_shift_map); dump_map(file, "option_map", fKeys.option_map); dump_map(file, "caps_shift_map", fKeys.caps_shift_map); dump_map(file, "caps_map", fKeys.caps_map); dump_map(file, "shift_map", fKeys.shift_map); dump_map(file, "normal_map", fKeys.normal_map); dump_keys(file, "acute_dead_key", fKeys.acute_dead_key); dump_keys(file, "grave_dead_key", fKeys.grave_dead_key); dump_keys(file, "circumflex_dead_key", fKeys.circumflex_dead_key); dump_keys(file, "dieresis_dead_key", fKeys.dieresis_dead_key); dump_keys(file, "tilde_dead_key", fKeys.tilde_dead_key); fprintf(file, "\tacute_tables:0x%" B_PRIx32 ",\n", fKeys.acute_tables); fprintf(file, "\tgrave_tables:0x%" B_PRIx32 ",\n", fKeys.grave_tables); fprintf(file, "\tcircumflex_tables:0x%" B_PRIx32 ",\n", fKeys.circumflex_tables); fprintf(file, "\tdieresis_tables:0x%" B_PRIx32 ",\n", fKeys.dieresis_tables); fprintf(file, "\ttilde_tables:0x%" B_PRIx32 ",\n", fKeys.tilde_tables); fprintf(file, "};\n\n"); fprintf(file, "const char kSystemKeyChars[] = {\n"); for (uint32 i = 0; i < fCharsSize; i++) { if (i % 10 == 0) { if (i > 0) fprintf(file, "\n"); fprintf(file, "\t"); } else fprintf(file, " "); fprintf(file, "0x%02x,", (uint8)fChars[i]); } fprintf(file, "\n};\n\n"); fprintf(file, "const uint32 kSystemKeyCharsSize = %" B_PRIu32 ";\n", fCharsSize); fclose(file); return B_OK; }