void genie_setup() { TString script_dir = gSystem->Getenv("GENIE"); script_dir += "/src/scripts/gcint/"; TString curr_dir = gSystem->pwd(); gSystem->cd(script_dir.Data()); gROOT->ProcessLine(".x loadincs.C"); gROOT->ProcessLine(".x loadlibs.C"); gSystem->cd(curr_dir.Data()); change_prompt(); }
static void process_commands(struct tgdb *tgdb) { struct tgdb_response *item; while ((item = tgdb_get_response(tgdb)) != NULL) { switch (item->header) { /* This updates all the breakpoints */ case TGDB_UPDATE_BREAKPOINTS: { struct sviewer *sview = if_get_sview(); char *file; struct tgdb_list *list = item->choice.update_breakpoints.breakpoint_list; tgdb_list_iterator *iterator; struct tgdb_breakpoint *tb; source_clear_breaks(if_get_sview()); iterator = tgdb_list_get_first(list); while (iterator) { /* For each breakpoint */ tb = (struct tgdb_breakpoint *) tgdb_list_get_item(iterator); file = tb->file; if (tb->enabled) source_enable_break(sview, file, tb->line); else source_disable_break(sview, file, tb->line); iterator = tgdb_list_next(iterator); } if_show_file(NULL, 0); break; } /* This means a source file or line number changed */ case TGDB_UPDATE_FILE_POSITION: { struct tgdb_file_position *tfp; tfp = item->choice.update_file_position.file_position; /* Update the file */ source_reload(if_get_sview(), tfp->absolute_path, 0); if_show_file(tfp->absolute_path, tfp->line_number); source_set_relative_path(if_get_sview(), tfp->absolute_path, tfp->relative_path); break; } /* This is a list of all the source files */ case TGDB_UPDATE_SOURCE_FILES: { struct tgdb_list *list = item->choice.update_source_files.source_files; tgdb_list_iterator *i = tgdb_list_get_first(list); char *s; if_clear_filedlg(); while (i) { s = tgdb_list_get_item(i); if_add_filedlg_choice(s); i = tgdb_list_next(i); } if_set_focus(FILE_DLG); kui_input_acceptable = 1; break; } /* The user is trying to get a list of source files that make up * the debugged program but libtgdb is claiming that gdb knows * none. */ case TGDB_SOURCES_DENIED: if_display_message("Error:", 0, " No sources available! Was the program compiled with debug?"); kui_input_acceptable = 1; break; /* This is the absolute path to the last file the user requested */ case TGDB_FILENAME_PAIR: { const char *apath = item->choice.filename_pair.absolute_path; const char *rpath = item->choice.filename_pair.relative_path; if_show_file((char *) apath, 1); source_set_relative_path(if_get_sview(), apath, rpath); break; } /* The source file requested does not exist */ case TGDB_ABSOLUTE_SOURCE_DENIED: { struct tgdb_source_file *file = item->choice.absolute_source_denied.source_file; if_show_file(NULL, 0); /* com can be NULL when tgdb orig requests main file */ if (file->absolute_path != NULL) if_display_message("No such file:", 0, " %s", file->absolute_path); break; } case TGDB_INFERIOR_EXITED: { /* * int *status = item->data; * This could eventually go here, but for now, the update breakpoint * display function makes the status bar go back to the name of the file. * * if_display_message ( "Program exited with value", 0, " %d", *status ); */ /* Clear the cache */ break; } case TGDB_UPDATE_COMPLETIONS: { struct tgdb_list *list = item->choice.update_completions.completion_list; do_tab_completion(list); break; } case TGDB_UPDATE_CONSOLE_PROMPT_VALUE: { const char *new_prompt = item->choice.update_console_prompt_value.prompt_value; change_prompt(new_prompt); break; } case TGDB_QUIT: cleanup(); exit(0); break; /* Default */ default: break; } } }
static void driver_prompt_change(const char *new_prompt) { char *nprompt = (char *) new_prompt; change_prompt(nprompt); }
int ps4sh_srv_read(int fd) { int length = 0; int ret = 0; struct { unsigned int number; unsigned short length; char buffer[512]; } PACKED packet; // Read in the request packet header. length=network_receive_all(request_socket, &packet, 6); if ( length < 0 ) { return length; } else if ( length == 0 ) { if ( fd == request_socket ) { close(fd); change_prompt(); while(1) { sleep(1); request_socket = ps4link_fio_listener(dst_ip, SRV_PORT, 1); if (request_socket > 0) { break; } } change_prompt(); } else { return -1; } } else { // Read in the rest of the packet. network_receive_all(request_socket, packet.buffer, ntohs(packet.length) - 6); switch(ntohl(packet.number)) { case PS4LINK_OPEN_CMD: if (VERBOSE) { gettimeofday(&benchtime, NULL); time1=(benchtime.tv_sec - time_base)*USEC+benchtime.tv_usec; } ps4link_request_open(&packet); break; case PS4LINK_CLOSE_CMD: if (VERBOSE) { gettimeofday(&benchtime, NULL); time2=(benchtime.tv_sec - time_base)*USEC+benchtime.tv_usec; debugNetPrintf(DEBUG,"took %2.3fs\n", ((float)(time2-time1)/(float)USEC)); } ps4link_request_close(&packet); break; case PS4LINK_READ_CMD: ps4link_request_read(&packet); break; case PS4LINK_WRITE_CMD: ps4link_request_write(&packet); break; case PS4LINK_LSEEK_CMD: ps4link_request_lseek(&packet); break; case PS4LINK_OPENDIR_CMD: ps4link_request_opendir(&packet); break; case PS4LINK_CLOSEDIR_CMD: ps4link_request_closedir(&packet); break; case PS4LINK_READDIR_CMD: ps4link_request_readdir(&packet); break; case PS4LINK_REMOVE_CMD: ps4link_request_remove(&packet); break; case PS4LINK_MKDIR_CMD: ps4link_request_mkdir(&packet); break; case PS4LINK_RMDIR_CMD: ps4link_request_rmdir(&packet); break; case PS4LINK_EXECELF_CMD: // ps4link_command_execelf(&packet); printf("Received execee request/command number (%x)\n",packet.number); break; case PS4LINK_EXECSPRX_CMD: // ps4link_command_execsprx(&packet); break; default: debugNetPrintf(DEBUG,"Received unsupported request/command number (%x)\n",packet.number); break; } } return 0; }
int main(int argc, char ** argv) { //get command line arguments int c; char * pvalue = NULL; while ((c = getopt (argc, argv, "p:")) != -1) { switch (c) { case 'p': pvalue = optarg; break; default: break; } } int cmd_type; //enumerated value to determine how command is executed int cmd_block; //whether to wait for child to exit or not int cmd_argc; //number of args counted while parsing char cmd_args[MAX_ARG_COUNT][MAX_INPUT_LENGTH]; //store command line args char * exec_args[MAX_ARG_COUNT]; //cmd_args incompatible type with execvp //ready prompt char prompt[MAX_INPUT_LENGTH]; init_prompt(prompt); if(pvalue != NULL) { change_prompt(prompt,pvalue); } char buffer[MAX_INPUT_LENGTH]; //general purpose string buffer int done = 0; do { //clear command buffer int i; for(i = 0; i < MAX_ARG_COUNT; i++) { cmd_args[i][0] = '\0'; } //get input print_prompt(prompt); scanf("\n"); scanf("%[^\n]",buffer); //store history strcpy(history[history_count],buffer); history_count++; //tokenize char * ptr = strtok(buffer," "); i = 0; while(ptr != NULL) { strcpy(cmd_args[i],ptr); ptr = strtok(NULL," "); i++; } argc = i; //set state based on input cmd_type = get_type(cmd_args[0]); cmd_block = get_block(cmd_args[argc-1]); int j; for(j = 0; j < argc; j++) { exec_args[j] = cmd_args[j]; } if(!cmd_block) //want to eliminate & { exec_args[argc-1] = NULL; } else //keep all args parsed { exec_args[argc] = NULL; } //check if any children exited int status, child_pid; child_pid = waitpid(-1,&status,WNOHANG); if(child_pid > 0) { get_status_str(status,child_pid,buffer); print_out(buffer); } //execute done = execute(cmd_type,cmd_block,cmd_args[0],exec_args); }while(!done); return 0; }
/** Procedure: commandHandler Purpose: Handles User Commands & Command Execution Parameters: None Return value: None Calls: displayWelcome, keyboardInput, cmpP2S, handler_help, handler_version, handler_set_date, handler_get_date, handler_display_mpx, handler_display_history, handler_terminate_mpx, change_prompt, handler_help_function, handler_create_pcb, handler_delete_pcb, handler_block, handler_unblock, handler_suspend, handler_resume, handler_set_priority, handler_show_pcb, handler_show, displayClosing, commandCleanup, sys_exit Globals: comDone, userCommand Errors: None **/ void commandHandler(){ int userCommandSize; displayWelcome(); //2.1 Display the Welcome Message while(comDone !=1){ //2.2 Begin While Loop for User Commands userCommand = NULL; printf("\nPlease enter the command to be executed(case sensitive).\n"); userCommand = keyboardInput(0); //2.2.1 Request User Input & Accept Command from User printf("\n"); //Decision Statement if(cmpP2S(userCommand, "help") == 1 || cmpP2S(userCommand, "/?") == 1){ handler_help(); } else if(cmpP2S(userCommand, "version") == 1){ handler_version(); } else if(cmpP2S(userCommand, "set_date") == 1){ handler_set_date(); //fix = 1; } else if(cmpP2S(userCommand, "get_date") == 1){ handler_get_date(); } else if(cmpP2S(userCommand, "display_mpx") == 1){ handler_display_mpx(); } //else if(cmpP2S(userCommand, "display_history") == 1){ // handler_display_history(); //} else if(cmpP2S(userCommand, "terminate_mpx") == 1||cmpP2S(userCommand, "exit") == 1||cmpP2S(userCommand, "quit") == 1){ handler_terminate_mpx(); } else if(cmpP2S(userCommand, "change_prompt") == 1){ change_prompt(); //fix = 1; } else if(cmpP2S(userCommand, "help_version")==1){ handler_help_function("version"); } else if(cmpP2S(userCommand, "help_set_date")==1){ handler_help_function("set_date"); } else if(cmpP2S(userCommand, "help_get_date")==1){ handler_help_function("get_date"); } else if(cmpP2S(userCommand, "help_display_mpx")==1){ handler_help_function("display_mpx"); } else if(cmpP2S(userCommand, "help_terminate_mpx")==1){ handler_help_function("terminate_mpx"); } else if(cmpP2S(userCommand, "help_change_prompt")==1){ handler_help_function("change_prompt"); } else if(cmpP2S(userCommand, "help_create_pcb")==1){ handler_help_function("create_pcb"); } else if(cmpP2S(userCommand, "create_pcb")==1){ handler_create_pcb(); } else if(cmpP2S(userCommand, "help_delete_pcb")==1){ handler_help_function("delete_pcb"); } else if(cmpP2S(userCommand, "delete_pcb")==1){ handler_delete_pcb(); } else if(cmpP2S(userCommand, "help_block")==1){ handler_help_function("block"); } else if(cmpP2S(userCommand, "block")==1){ handler_block(); } else if(cmpP2S(userCommand, "help_unblock")==1){ handler_help_function("unblock"); } else if(cmpP2S(userCommand, "unblock")==1){ handler_unblock(); } else if(cmpP2S(userCommand, "help_suspend")==1){ handler_help_function("suspend"); } else if(cmpP2S(userCommand, "suspend")==1){ handler_suspend(); } else if(cmpP2S(userCommand, "help_resume")==1){ handler_help_function("resume"); } else if(cmpP2S(userCommand, "resume")==1){ handler_resume(); } else if(cmpP2S(userCommand, "help_set_priority")==1){ handler_help_function("set_priority"); } else if(cmpP2S(userCommand, "set_priority")==1){ handler_set_priority(); } else if(cmpP2S(userCommand, "help_show_pcb")==1){ handler_help_function("show_pcb"); } else if(cmpP2S(userCommand, "show_pcb")==1){ handler_show_pcb(); } else if(cmpP2S(userCommand, "help_show_all")==1){ handler_help_function("show_all"); } else if(cmpP2S(userCommand, "show_all")==1){ handler_show(0); } else if(cmpP2S(userCommand, "help_show_ready")==1){ handler_help_function("show_ready"); } else if(cmpP2S(userCommand, "show_ready")==1){ handler_show(4); handler_show(6); } else if(cmpP2S(userCommand, "help_show_blocked")==1){ handler_help_function("show_blocked"); } else if(cmpP2S(userCommand, "show_blocked")==1){ handler_show(5); handler_show(7); } else { printf("Invalid Command.\n"); }//end if - Decision }//end while displayClosing(); //2.2.4 Display closing message commandCleanup(); //2.2.5 Cleanup Allocated Memory keyboardInput(0); sys_exit(); //2.2.6 Return to host system }