static char * top_level_prompt (void) { char *prefix; char *prompt = NULL; char *suffix; char *composed_prompt; size_t prompt_length; /* Give observers a chance of changing the prompt. E.g., the python `gdb.prompt_hook' is installed as an observer. */ observer_notify_before_prompt (get_prompt ()); prompt = xstrdup (get_prompt ()); if (annotation_level >= 2) { /* Prefix needs to have new line at end. */ prefix = (char *) alloca (strlen (async_annotation_suffix) + 10); strcpy (prefix, "\n\032\032pre-"); strcat (prefix, async_annotation_suffix); strcat (prefix, "\n"); /* Suffix needs to have a new line at end and \032 \032 at beginning. */ suffix = (char *) alloca (strlen (async_annotation_suffix) + 6); strcpy (suffix, "\n\032\032"); strcat (suffix, async_annotation_suffix); strcat (suffix, "\n"); } else { prefix = ""; suffix = ""; } prompt_length = strlen (prefix) + strlen (prompt) + strlen (suffix); composed_prompt = (char *) xmalloc (prompt_length + 1); strcpy (composed_prompt, prefix); strcat (composed_prompt, prompt); strcat (composed_prompt, suffix); xfree (prompt); return composed_prompt; }
/* SETUP ROUTINES */ int initial_set() { int prompt,status; /* On node zero, read lattice size, seed, nflavors and send to others */ if(mynode()==0) { /* print banner */ printf("SU3 with Wilson fermions\n"); printf("Microcanonical simulation with refreshing\n"); printf("MIMD version 6\n"); printf("Machine = %s, with %d nodes\n",machine_type(),numnodes()); #ifdef HMC_ALGORITHM printf("Hybrid Monte Carlo algorithm\n"); #endif #ifdef PHI_ALGORITHM printf("PHI algorithm\n"); #else printf("R algorithm\n"); #endif #ifdef SPECTRUM printf("With spectrum measurements\n"); #endif time_stamp("start"); status = get_prompt(stdin, &prompt); IF_OK status += get_i(stdin, prompt, "nflavors", &par_buf.nflavors ); #ifdef PHI_ALGORITHM if( par_buf.nflavors != 2) { printf("Dummy! Use phi algorithm only for two flavors\n"); terminate(-1); } #endif IF_OK status += get_i(stdin, prompt, "nx", &par_buf.nx ); IF_OK status += get_i(stdin, prompt, "ny", &par_buf.ny ); IF_OK status += get_i(stdin, prompt, "nz", &par_buf.nz ); IF_OK status += get_i(stdin, prompt, "nt", &par_buf.nt ); IF_OK status += get_i(stdin, prompt, "iseed", &par_buf.iseed ); if(status>0) par_buf.stopflag=1; else par_buf.stopflag=0; } /* end if(mynode()==0) */ /* Node 0 broadcasts parameter buffer to all other nodes */ broadcast_bytes((char *)&par_buf,sizeof(par_buf)); if( par_buf.stopflag != 0 ) normal_exit(0); nx=par_buf.nx; ny=par_buf.ny; nz=par_buf.nz; nt=par_buf.nt; iseed=par_buf.iseed; nflavors=par_buf.nflavors; this_node = mynode(); number_of_nodes = numnodes(); volume=nx*ny*nz*nt; total_iters=0; return(prompt); }
static char *fetchline(void) { char *line = readline(get_prompt()); if (line && *line) { add_history(line); } return line; }
/* SETUP ROUTINES */ int initial_set(){ int prompt,status; /* On node zero, read lattice size, seed, and send to others */ if(mynode()==0){ /* print banner */ printf("SU3 with improved KS action\n"); printf("Eigenvalues and eigenvectors\n"); printf("MIMD version 6\n"); printf("Machine = %s, with %d nodes\n",machine_type(),numnodes()); gethostname(hostname, 128); printf("Host(0) = %s\n",hostname); printf("Username = %s\n", getenv("USER")); time_stamp("start"); get_utc_datetime(utc_date_time); /* Print list of options selected */ node0_printf("Options selected...\n"); show_generic_opts(); show_generic_ks_opts(); #if FERM_ACTION == HISQ show_su3_mat_opts(); show_hisq_links_opts(); #elif FERM_ACTION == HYPISQ show_su3_mat_opts(); show_hypisq_links_opts(); #endif status=get_prompt(stdin, &prompt); IF_OK status += get_i(stdin, prompt,"nx", &par_buf.nx ); IF_OK status += get_i(stdin, prompt,"ny", &par_buf.ny ); IF_OK status += get_i(stdin, prompt,"nz", &par_buf.nz ); IF_OK status += get_i(stdin, prompt,"nt", &par_buf.nt ); IF_OK status += get_i(stdin, prompt,"iseed", &par_buf.iseed ); if(status>0) par_buf.stopflag=1; else par_buf.stopflag=0; } /* end if(mynode()==0) */ /* Node 0 broadcasts parameter buffer to all other nodes */ broadcast_bytes((char *)&par_buf,sizeof(par_buf)); if( par_buf.stopflag != 0 ) normal_exit(0); nx=par_buf.nx; ny=par_buf.ny; nz=par_buf.nz; nt=par_buf.nt; iseed=par_buf.iseed; this_node = mynode(); number_of_nodes = numnodes(); volume=nx*ny*nz*nt; total_iters=0; return(prompt); }
void signal_handler(int signo) { if (signo == SIGINT) { ft_putstr("\n"); get_prompt(); signal(SIGINT, signal_handler); } }
/* SETUP ROUTINES */ int initial_set(){ int prompt,status; #ifdef FIX_NODE_GEOM int i; #endif /* On node zero, read lattice size and send to others */ if(mynode()==0){ /* print banner */ printf("SU3 clover valence fermions\n"); printf("MIMD version 7 $Name: $\n"); printf("Machine = %s, with %d nodes\n",machine_type(),numnodes()); time_stamp("start"); status = get_prompt(stdin, &prompt ); IF_OK status += get_i(stdin,prompt,"nx", ¶m.nx ); IF_OK status += get_i(stdin,prompt,"ny", ¶m.ny ); IF_OK status += get_i(stdin,prompt,"nz", ¶m.nz ); IF_OK status += get_i(stdin,prompt,"nt", ¶m.nt ); #ifdef FIX_NODE_GEOM IF_OK status += get_vi(stdin, prompt, "node_geometry", param.node_geometry, 4); #ifdef FIX_IONODE_GEOM IF_OK status += get_vi(stdin, prompt, "ionode_geometry", param.ionode_geometry, 4); #endif #endif IF_OK status += get_s(stdin, prompt,"job_id",param.job_id); if(status>0) param.stopflag=1; else param.stopflag=0; } /* end if(mynode()==0) */ /* Node 0 broadcasts parameter buffer to all other nodes */ broadcast_bytes((char *)¶m,sizeof(param)); if( param.stopflag != 0 ) normal_exit(0); nx=param.nx; ny=param.ny; nz=param.nz; nt=param.nt; #ifdef FIX_NODE_GEOM for(i = 0; i < 4; i++) node_geometry[i] = param.node_geometry[i]; #ifdef FIX_IONODE_GEOM for(i = 0; i < 4; i++) ionode_geometry[i] = param.ionode_geometry[i]; #endif #endif this_node = mynode(); number_of_nodes = numnodes(); volume=nx*ny*nz*nt; return(prompt); }
static int load_string (void) { int status; lua_settop(L, 0); if (lua_readline(L, get_prompt(1)) == 0) /* no input? */ return -1; if (lua_tostring(L, -1)[0] == '=') { /* line starts with `=' ? */ lua_pushfstring(L, "return %s", lua_tostring(L, -1)+1);/* `=' -> `return' */ lua_remove(L, -2); /* remove original line */ } for (;;) { /* repeat until gets a complete line */ status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin"); if (!incomplete(status)) break; /* cannot try to add lines? */ if (lua_readline(L, get_prompt(0)) == 0) /* no more input? */ return -1; lua_concat(L, lua_gettop(L)); /* join lines */ } lua_saveline(L, lua_tostring(L, 1)); lua_remove(L, 1); /* remove line */ return status; }
static void cmd_help(int argcp, char **argvp) { int i; for (i = 0; commands[i].cmd; i++) printf("%-15s %-30s %s\n", commands[i].cmd, commands[i].params, commands[i].desc); printf("\n%s", get_prompt()); fflush(stdout); }
void readline_print_status() { char str_prompt[STR_SIZE]; #if 0 term_puts("myshell"); term_putc(get_prompt()); term_putc(' '); #endif sprintf(str_prompt, "%s@%s:%s%c ", get_username(), get_nodename(), get_current_short_dir(), get_prompt()); term_puts(str_prompt); }
static void cmd_read_uuid(int argcp, char **argvp) { struct characteristic_data *char_data; int start = 0x0001; int end = 0xffff; bt_uuid_t uuid; if (conn_state != STATE_CONNECTED) { printf("Command failed: disconnected\n"); goto done; } if (argcp < 2) { printf("Missing argument: UUID\n"); goto done; } if (bt_string_to_uuid(&uuid, argvp[1]) < 0) { printf("Invalid UUID\n"); goto done; } if (argcp > 2) { start = strtohandle(argvp[2]); if (start < 0) { printf("Invalid start handle: %s\n", argvp[1]); goto done; } } if (argcp > 3) { end = strtohandle(argvp[3]); if (end < 0) { printf("Invalid end handle: %s\n", argvp[2]); goto done; } } char_data = g_new(struct characteristic_data, 1); char_data->orig_start = start; char_data->start = start; char_data->end = end; char_data->uuid = uuid; gatt_read_char_by_uuid(attrib, start, end, &char_data->uuid, char_read_by_uuid_cb, char_data); done: printf("\r%s", get_prompt()); fflush(stdout); }
static char *fetchline_readline(void) { char *line = NULL; readline_start(readline_state, get_prompt(), 0, readline_func, &line); while (!line) { int ch = getchar(); if (ch == EOF) { break; } readline_handle_byte(readline_state, ch); } return line; }
int set_hostname (const char *Hostname) { int this_session = cli_get_cli_session_id (); if (this_session < 0) return -1; sprintf (this_cli[this_session].hostname, "%s", Hostname); set_prompt ("(config)"); get_prompt (this_cli[this_session].parser.cfg.prompt); return 0; }
/* APPLE LOCAL begin Inform user about debugging optimized code */ void adjust_prompts_for_optimized_code (void) { /* Case 1: gdb_prompt_is_optimized == false. */ if (!gdb_prompt_is_optimized) { /* If we're inside optimized code AND the user wants to be told about it, append '[opt> ' to the prompt. Actually, create a second duplicate prompt, and append to that. This allows for easy removal later. */ if (dwarf2_inform_debugging_optimized_code && currently_inside_optimized_code) { char *old_prompt = get_prompt (); char *new_prompt; if (strstr (old_prompt, "[opt> ") == 0) { new_prompt = (char *) xmalloc (strlen (old_prompt) + 7); sprintf (new_prompt, "%s[opt> ", old_prompt); push_prompt ("", new_prompt, ""); xfree (new_prompt); } gdb_prompt_is_optimized = 1; } } /* Case 2: gdb_prompt_is_optimized == true. */ else if (gdb_prompt_is_optimized) { /* If we're not inside optimized code, or the user does not want to be told about it, pop the '[opt> ' version of the prompt from the prompt stack. */ if (!dwarf2_inform_debugging_optimized_code || !currently_inside_optimized_code) { if (the_prompts.top > 0 && strstr (PROMPT (0), "[opt> ") != 0) { xfree (PREFIX (0)); xfree (PROMPT (0)); xfree (SUFFIX (0)); the_prompts.top--; } gdb_prompt_is_optimized = 0; } } }
char * fetchline(void) { char *line; if (inputstacksize == 1) { line = readline(get_prompt()); if (line && *line) { add_history(line); logprintf("%s", line); } } else { line = fetchline_internal(); } return line; }
// ----------------------------------------------------------------- // On node zero, read and distribute lattice size and random number seed int initial_set() { int prompt, status; if (mynode() == 0) { // Print banner printf("SU3 Kogut--Susskind eigenvalue calculation\n"); printf("Machine = %s, with %d nodes\n", machine_type(), numnodes()); printf("nHYP links, reading alpha_smear parameters from infile\n"); printf(" IR_STAB = %.4g\n", (Real)IR_STAB); printf(" EPS_SQ = %.4g\n", (Real)EPS_SQ); #ifdef NHYP_DEBUG printf("NHYP_DEBUG turned on\n"); #endif #ifdef NO_UNIT_CHECK printf("NOT checking unitarity when loading lattice\n"); #endif time_stamp("start"); status = get_prompt(stdin, &prompt); IF_OK status += get_i(stdin, prompt, "nx", &par_buf.nx); IF_OK status += get_i(stdin, prompt, "ny", &par_buf.ny); IF_OK status += get_i(stdin, prompt, "nz", &par_buf.nz); IF_OK status += get_i(stdin, prompt, "nt", &par_buf.nt); IF_OK status += get_i(stdin, prompt, "iseed", &par_buf.iseed); if (status > 0) par_buf.stopflag = 1; else par_buf.stopflag = 0; } // Broadcast parameter buffer from node 0 to all other nodes broadcast_bytes((char *)&par_buf, sizeof(par_buf)); if (par_buf.stopflag != 0) normal_exit(0); nx = par_buf.nx; ny = par_buf.ny; nz = par_buf.nz; nt = par_buf.nt; iseed = par_buf.iseed; this_node = mynode(); number_of_nodes = numnodes(); volume = nx * ny * nz * nt; total_iters = 0; return(prompt); }
static void cmd_char(int argcp, char **argvp) { int start = 0x0001; int end = 0xffff; if (conn_state != STATE_CONNECTED) { printf("Command failed: disconnected\n"); goto done; } if (argcp > 1) { start = strtohandle(argvp[1]); if (start < 0) { printf("Invalid start handle: %s\n", argvp[1]); goto done; } } if (argcp > 2) { end = strtohandle(argvp[2]); if (end < 0) { printf("Invalid end handle: %s\n", argvp[2]); goto done; } } if (argcp > 3) { bt_uuid_t uuid; if (bt_string_to_uuid(&uuid, argvp[3]) < 0) { printf("Invalid UUID\n"); goto done; } g_attrib_ref(attrib); gatt_discover_char(attrib, start, end, &uuid, char_cb, NULL); return; } g_attrib_ref(attrib); gatt_discover_char(attrib, start, end, NULL, char_cb, NULL); return; done: printf("\r%s", get_prompt()); fflush(stdout); }
/* SETUP ROUTINES */ int initial_set(){ int prompt,status; /* On node zero, read lattice size, seed, nflavors and send to others */ if(mynode()==0){ /* print banner */ printf("Schroedinger functional for pure gauge SU3\n"); #ifdef RMD_ALGORITHM printf("Microcanonical simulation with refreshing\n"); #endif #ifdef HMC_ALGORITHM printf("Microcanonical simulation with refreshing\n"); #endif printf("MIMD version 6\n"); printf("Machine = %s, with %d nodes\n",machine_type(),numnodes()); #ifdef HMC_ALGORITHM printf("Hybrid Monte Carlo algorithm\n"); #endif #ifdef ORA_ALGORITHM printf("Overrelaxed/quasi-heat bath algorithm\n"); #endif status=get_prompt(stdin, &prompt); IF_OK status += get_i(stdin, prompt,"nx", &par_buf.nx ); IF_OK status += get_i(stdin, prompt,"ny", &par_buf.ny ); IF_OK status += get_i(stdin, prompt,"nz", &par_buf.nz ); IF_OK status += get_i(stdin, prompt,"nt", &par_buf.nt ); IF_OK status += get_i(stdin, prompt,"iseed", &par_buf.iseed ); if(status>0) par_buf.stopflag=1; else par_buf.stopflag=0; } /* end if(mynode()==0) */ /* Node 0 broadcasts parameter buffer to all other nodes */ broadcast_bytes((char *)&par_buf,sizeof(par_buf)); if( par_buf.stopflag != 0 ) normal_exit(0); nx=par_buf.nx; ny=par_buf.ny; nz=par_buf.nz; nt=par_buf.nt; iseed=par_buf.iseed; this_node = mynode(); number_of_nodes = numnodes(); volume=nx*ny*nz*nt; return(prompt); }
int main_loop (void) { fd_set readfds; int rc, numfds, sock, kkk; rl_callback_handler_install (get_prompt (), rl_read_cli); sock = GET_FILE_DESCRIPTOR (&main_sock); do { numfds = -1; FD_ZERO (&readfds); kkk = 0; /* stdin for commands */ FD_SET (kkk, &readfds); if (kkk > numfds) numfds = kkk; FD_SET (sock, &readfds); if (sock > numfds) numfds = sock; if (numfds < 0) numfds = 0; else numfds++; rc = select (numfds, &readfds, NULL, NULL, NULL); if (rc < 0) { // Error if (EINTR == errno) continue; // don't break printf ("FATAL_MODE:select failed: %s\n", strerror (errno)); return -2; } if (FD_ISSET (0, &readfds)) { rl_callback_read_char (); } if (FD_ISSET (sock, &readfds)) { shutdown_flag |= read_uid (); } } while (!shutdown_flag); return 0; }
static void cmd_sec_level(int argcp, char **argvp) { GError *gerr = NULL; BtIOSecLevel sec_level; if (argcp < 2) { printf("sec-level: %s\n", opt_sec_level); goto done; } if (strcasecmp(argvp[1], "medium") == 0) sec_level = BT_IO_SEC_MEDIUM; else if (strcasecmp(argvp[1], "high") == 0) sec_level = BT_IO_SEC_HIGH; else if (strcasecmp(argvp[1], "low") == 0) sec_level = BT_IO_SEC_LOW; else { printf("Allowed values: low | medium | high\n"); goto done; } g_free(opt_sec_level); opt_sec_level = g_strdup(argvp[1]); if (conn_state != STATE_CONNECTED) goto done; if (opt_psm) { printf("It must be reconnected to this change take effect\n"); goto done; } bt_io_set(iochannel, BT_IO_L2CAP, &gerr, BT_IO_OPT_SEC_LEVEL, sec_level, BT_IO_OPT_INVALID); if (gerr) { printf("Error: %s\n", gerr->message); g_error_free(gerr); } return; done: printf("\r%s", get_prompt()); fflush(stdout); }
void *cmdinterface(void *unused) { int session = (int)unused; cparser_result_t rc; this_cli[session].taskid = tsk_selfid (); get_prompt (this_cli[session].parser.cfg.prompt); cli_set_vlan_id (1); rc = cparser_init(&this_cli[session].parser.cfg, &this_cli[session].parser); cparser_run(&this_cli[session].parser); return NULL; }
static int pushline (lua_State *L, int firstline) { char buffer[LUA_MAXINPUT]; char *b = buffer; size_t l; const char *prmt = get_prompt(L, firstline); if (lua_readline(L, b, prmt) == 0) return 0; /* no input */ l = strlen(b); if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ b[l-1] = '\0'; /* remove it */ if (firstline && b[0] == '=') /* first line starts with `=' ? */ lua_pushfstring(L, "return %s", b+1); /* change it to `return' */ else lua_pushstring(L, b); lua_freeline(L, b); return 1; }
static int pushline (lua_State *L, int firstline) { char buffer[LUA_MAXINPUT]; char *b = buffer; size_t l; const char *prmt = get_prompt(L, firstline); if (lua_readline(L, b, prmt) == 0) return 0; l = strlen(b); if (l > 0 && b[l-1] == '\n') b[l-1] = '\0'; if (firstline && b[0] == '=') lua_pushfstring(L, "return %s", b+1); else lua_pushstring(L, b); lua_freeline(L, b); return 1; }
static void shell(void *p1, void *p2, void *p3) { ARG_UNUSED(p1); ARG_UNUSED(p2); ARG_UNUSED(p3); while (1) { struct console_input *cmd; printk("%s", get_prompt()); cmd = k_fifo_get(&cmds_queue, K_FOREVER); shell_exec(cmd->line); k_fifo_put(&avail_queue, cmd); } }
/* * Readline init. */ int initialize_readline(void) { rl_bind_key_in_map(META ('p'), cli_pwd, emacs_standard_keymap); rl_bind_key_in_map(META ('q'), cli_quit, emacs_standard_keymap); rl_bind_key_in_map(META ('s'), cli_status, emacs_standard_keymap); rl_bind_key_in_map(META ('v'), cli_verbose, emacs_standard_keymap); rl_readline_name = "ps4sh"; rl_attempted_completion_function = command_completion; rl_ignore_some_completions_function = filename_completion_ignore; if (strcmp(ps4sh_history, "") != 0) { if (read_history(ps4sh_history) != 0) { perror(ps4sh_history); } } rl_callback_handler_install(get_prompt(), cli_handler); return 0; }
static int pushline(lua_State *L, bool firstline) { char buffer[BUFSIZ]; char *b = buffer; size_t l; const char *prmt = get_prompt(L, firstline); b = buffer; /* use static buffer */ fputs(prmt, stdout); fflush(stdout);/* show prompt */ if (!fgets(b, BUFSIZ, stdin)) /* get line */ return 0; /* no input */ l = strlen(b); if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ b[l-1] = '\0'; /* remove it */ if (firstline && b[0] == '=') /* first line starts with `=' ? */ lua_pushfstring(L, "return %s", b+1); /* change it to `return' */ else lua_pushstring(L, b); return 1; }
char * fetchline(void) { char *p, *line = malloc(MAXREADLINESZ); if (!line) return NULL; printf("%s", get_prompt()); fflush(stdout); if (!fgets(line, MAXREADLINESZ, stdin)) { free(line); return NULL; } p = line + strlen(line); if (p != line && p[-1] == '\n') p[-1] = '\0'; return line; }
static int pushline (LUA_State *L, int firstline) { char buffer[LUA_MAXINPUT]; char *b = buffer; size_t l; const char *prmt = get_prompt(L, firstline); int readstatus = LUA_readline(L, b, prmt); LUA_pop(L, 1); /* remove result from 'get_prompt' */ if (readstatus == 0) return 0; /* no input */ l = strlen(b); if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ b[l-1] = '\0'; /* remove it */ if (firstline && b[0] == '=') /* first line starts with `=' ? */ LUA_pushfstring(L, "RETURN %s", b+1); /* change it to `return' */ else LUA_pushstring(L, b); LUA_freeline(L, b); return 1; }
void ga_controller::start() { // Start the state machine initiate(); //cmds_waiting = 0; io_work = std::make_unique< asio::io_service::work >(io_service); // temp io_service.post([this] { // process_event(clsm::ev_cmd< init_cmd >{}); }); // prompt_callback(get_prompt()); io_service.run(); }
/* ** Prompt the user, read a line, and push it into the Lua stack. */ static int pushline (lua_State *L, int firstline) { char buffer[LUA_MAXINPUT]; char *b = buffer; size_t l; const char *prmt = get_prompt(L, firstline); int readstatus = lua_readline(L, b, prmt); if (readstatus == 0) return 0; /* no input (prompt will be popped by caller) */ lua_pop(L, 1); /* remove prompt */ l = strlen(b); if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ b[--l] = '\0'; /* remove it */ if (firstline && b[0] == '=') /* for compatibility with 5.2, ... */ lua_pushfstring(L, "return %s", b + 1); /* change '=' to 'return' */ else lua_pushlstring(L, b, l); lua_freeline(L, b); return 1; }
static int pushline(lua_State *L, int firstline) { char buffer[LUA_MAXINPUT]; char *buf = buffer; size_t len; const char *prmt = get_prompt(L, firstline); if (lua_readline(L, buf, prmt)) { lua_pop(L, 1); /* prompt */ len = strlen(buf); if (len > 0 && buf[len-1] == '\n') buf[len-1] = '\0'; if (firstline && buf[0] == '=') lua_pushfstring(L, "return %s", buf+1); else lua_pushstring(L, buf); return 1; } return 0; }