void rectangles(double n) { double a = 0; double b = 5000; double i = a; double h = (b - a) / 10000; double result = 0; while (i < b) { result = result + produit(n, (a + i * h)); i = i + 1; } result = result * h; prompt(result, result - (M_PI / 2), n, 1); }
void minishell2(char **env) { char *bufpath[2]; char **tab; char **cmd; while (42) { bufpath[0] = prompt(); check_exit(bufpath[0]); bufpath[1] = get_path(env); tab = my_str_to_wordtab(bufpath[1]); cmd = my_str_to_wordtab2(bufpath[0]); process(bufpath, tab, cmd, env); } }
//Function for handling signals void signalhandling(int signum) { if(signum==20) kill(pp,20); if(signum==2 || signum ==3) { fflush(stdout); printf("\n"); prompt(); fflush(stdout); signal(SIGINT, signalhandling); signal(SIGQUIT, signalhandling); signal(SIGTSTP,signalhandling); } return; }
void * shell(void *arg) { int c; int rc=1; int menu=1; while (1) { if ((c=prompt(menu))!=0) rc=docmd(c); if (rc<0) break; if (rc==1) menu=1; else menu=0; } fprintf(stderr, "terminating\n"); fflush(stdout); return NULL; }
void trapezes(double n) { double a = 0; double b = 5000; double i = 1; double h = (b - a) / 10000; double result = 0; while (i < b) { result = result + produit(n, (a + i * h)); i = i + 1; } result = ((result * 2) + produit(n, a) + produit(n, b)) * ((b - a) / 20000); prompt(result, result - (M_PI / 2), n, 2); }
int sgetch(const char *p, struct ship *ship, char flag) { int c; prompt(p, ship); blockalarm(); wrefresh(scroll_w); unblockalarm(); while ((c = wgetch(scroll_w)) == EOF) ; if (flag && c >= ' ' && c < 0x7f) waddch(scroll_w, c); endprompt(flag); return c; }
int main(int argc, char** argv) { setup_error_handling(); if (argc > 1) { int* script_argc = (int*)malloc(sizeof(int)); char** script_and_args = parseopts(argc, argv, script_argc); if (*(script_argc)) { return script(*(script_argc), script_and_args); } return 0; } else { print_version_info(argv[0]); return prompt(); } }
/** * Method handling the downgrade interface for the installations */ void CLIStadiumView::showDowngradeInstallation() { size_t choice; cout << "Enter the number of the installation you want to downgrade" << endl; prompt(); cin >> choice; if (choice < user().installations.size()) { downgradeInstallation(choice); _wait = true; } else { cout << "The number you entered is wrong" << endl; } }
void nsNSSCertificateDB::DisplayCertificateAlert(nsIInterfaceRequestor *ctx, const char *stringID, nsIX509Cert *certToShow) { nsPSMUITracker tracker; if (!tracker.isUIForbidden()) { nsCOMPtr<nsIInterfaceRequestor> my_cxt = ctx; if (!my_cxt) my_cxt = new PipUIContext(); // This shall be replaced by embedding ovverridable prompts // as discussed in bug 310446, and should make use of certToShow. nsresult rv; nsCOMPtr<nsINSSComponent> nssComponent(do_GetService(kNSSComponentCID, &rv)); if (NS_SUCCEEDED(rv)) { nsAutoString tmpMessage; nssComponent->GetPIPNSSBundleString(stringID, tmpMessage); // The interface requestor object may not be safe, so proxy the call to get // the nsIPrompt. nsCOMPtr<nsIInterfaceRequestor> proxiedCallbacks; NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD, NS_GET_IID(nsIInterfaceRequestor), my_cxt, NS_PROXY_SYNC, getter_AddRefs(proxiedCallbacks)); nsCOMPtr<nsIPrompt> prompt (do_GetInterface(proxiedCallbacks)); if (!prompt) return; // Finally, get a proxy for the nsIPrompt nsCOMPtr<nsIPrompt> proxyPrompt; NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD, NS_GET_IID(nsIPrompt), prompt, NS_PROXY_SYNC, getter_AddRefs(proxyPrompt)); proxyPrompt->Alert(nsnull, tmpMessage.get()); } } }
/* * Fork a program with: * 0 <-> remote tty in * 1 <-> remote tty out * 2 <-> local tty stderr out */ void consh(int c) { char buf[256]; int cpid, status, p; sig_handler_t ointr, oquit; time_t start; (void) putchar(c); if (prompt("Local command? ", buf, sizeof (buf))) return; (void) kill(pid, SIGIOT); /* put TIPOUT into a wait state */ (void) read(repdes[0], (char *)&ccc, 1); ointr = signal(SIGINT, SIG_IGN); oquit = signal(SIGQUIT, SIG_IGN); unraw(); /* * Set up file descriptors in the child and * let it go... */ if ((cpid = fork()) < 0) (void) printf("can't fork!\r\n"); else if (cpid) { start = time(0); while ((p = wait(&status)) > 0 && p != cpid) ; raw(); (void) signal(SIGINT, ointr); (void) signal(SIGQUIT, oquit); } else { int i; userperm(); (void) dup2(FD, 0); (void) dup2(0, 1); for (i = 3; i < 20; i++) (void) close(i); (void) signal(SIGINT, SIG_DFL); (void) signal(SIGQUIT, SIG_DFL); execute(buf); (void) printf("can't find `%s'\r\n", buf); exit(0); } if (boolean(value(VERBOSE))) prtime("\r\naway for ", time(0)-start); (void) write(fildes[1], (char *)&ccc, 1); }
void loop() { while (Serial.available()) // If serial data is available on the port { inByte = (char)Serial.read(); // Read a byte if (echo) Serial.print(inByte); // If the scho is on then print it back to the host if (inByte == '\r') // Once a /r is recvd check to see if it's a good command { if (echo) Serial.println(); // Dummy empty line if (inData == "up") lift_arm(); else if (inData == "downs") down_seek(50, 0); // Lower arm until it finds bottom else if (inData == "down") down(50, ARM_DN_POSITION); // Blindly lower arm else if (inData == "pump on") pump(ON); // Start pump else if (inData == "pump off") pump(OFF); // Stop pump else if (inData == "vent") pump_release(); // Stop pump and vent the vacuum else if (inData == "left") baseLeft(16); // Move base to the left else if (inData == "center") findCenter(); // Move base to the right else if (inData == "right") baseRight(BASE_CENTER_POSITION);// Move base to the right else if (inData == "stop") baseStop(); // Stop base else if (inData == "home") left_home(); // Mode base left until it finds home else if (inData == "status") stats(); // Show current status else if (inData == "stats") stats(); // Show current stats else if (inData == "get disk") get_disk(); // Macro to get disk and lift to top else if (inData == "load disk") load_disk(); // Macro to get disk and move to center else if (inData == "unload disk") unload_disk(); // Macro to get disk and move to center else if (inData == "place disk") place_disk(); // Macro to lower disk into tray else if (inData == "debug on") debug_mode = true; // turn on debug mode, prints encoder values else if (inData == "debug off") debug_mode = false; // Turn off debug mode else if (inData == "echo on") echo = true; // Turn on echo mode else if (inData == "echo off") echo = false; // Turn off echo mode else // The string wasn't recognized so it was a bad command { Serial.print("Error, Unknown Command: "); // Show the error Serial.println(inData); // Echo the command } inData = ""; // Clear the buffer (string) if (echo) prompt(); // reprint the prompt } else inData += inByte; // If it's not a /r then keep adding to the string (buffer) } }
int main(int argc, char **argv) { int pid; // size_t len; if (argc != 3) { ft_putendl("Invalid number of argument."); exit(0); } signal(SIGUSR2, handler); pid = ft_atoi(argv[1]); // len = ft_strlen(argv[2]); // ft_send_len(pid, len); prompt(pid, argv[2]); return (0); }
int init_values(int *history_pl, int *reverse_case, char **str, char **cmd) { *history_pl = 0; *reverse_case = 0; if (((*str) = malloc(sizeof(**str) * 5)) == NULL || ((*cmd) = malloc(sizeof(**cmd) * 2)) == NULL) { if ((*str) != NULL) free(*str); return (-1); } (*str) = my_memset((*str), 0, 5); (*cmd) = my_memset((*cmd), 0, 2); prompt(TRUE); return (0); }
void waitforexit(void) { printf("Press A to get back to main menu.\n"); struct controller_data_s controller; while(1) { struct controller_data_s button; if (get_controller_data(&button, 0)) { if((button.a)&&(!controller.a)) prompt(MAIN_MENU); controller=button; } usb_do_poll(); } }
int shell(int argc, char ** argv) { /* Buffer de almacenamiento de caracteres */ char in_buffer[MAX_CHARS]; set_screen(); clear_screen(); welcome(); while(1) { prompt(); getline(in_buffer,MAX_CHARS); // proceso el comando almacenado en in_buffer bash(in_buffer); } return 1 ; }
/* * Fork a program with: * 0 <-> remote tty in * 1 <-> remote tty out * 2 <-> local tty stderr */ void consh(int c) { char buf[256]; int status, p; pid_t cpid; time_t start = time(NULL); putchar(c); if (prompt("Local command? ", buf, sizeof(buf))) return; kill(tipout_pid, SIGIOT); /* put TIPOUT into a wait state */ signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); tcsetattr(0, TCSAFLUSH, &defchars); read(repdes[0], (char *)&ccc, 1); /* * Set up file descriptors in the child and * let it go... */ if ((cpid = fork()) < 0) printf("can't fork!\r\n"); else if (cpid) { start = time(0); while ((p = wait(&status)) > 0 && p != cpid) ; } else { int i; dup2(FD, 0); dup2(3, 1); for (i = 3; i < 20; i++) close(i); signal(SIGINT, SIG_DFL); signal(SIGQUIT, SIG_DFL); execute(buf); printf("can't find `%s'\r\n", buf); exit(0); } if (boolean(value(VERBOSE))) prtime("away for ", time(0)-start); write(fildes[1], (char *)&ccc, 1); tcsetattr(0, TCSAFLUSH, &term); signal(SIGINT, SIG_DFL); signal(SIGQUIT, SIG_DFL); }
////////////////////////////// The main land ////////////////////////////// int main(int argc, char* argv[]){ int flags[6] = {0,0,0,0,0,0}; //flags = [t | n | p | v | c | q ] int num_thread=0, num_astr=0 ; obj *astr; thread_info t_info; int t = 1; // t is a preiod of time measure in a second int max_t=1000; thread_argv *targv; pthread_t *t_id; argv_handler(argc, argv, flags); prompt(&num_thread, &num_astr, &t_info, &astr, flags, &max_t); ini_astr(num_astr, astr); targv = malloc(sizeof(thread_argv)*num_thread); for(int a = 0; a < num_thread; a++){ targv[a].num_astr = num_astr; targv[a].astr = astr; targv[a].t_info = malloc(sizeof(thread_info)); targv[a].t = t; } //FIXME: while time steps goes here for(int time = 0; time < max_t; time++){ pthread_barrier_init(&barrier, NULL, num_thread); t_id = hive(num_thread, targv ); for(int k=0; k<num_thread; ++k){ if(pthread_join(t_id[k],NULL)!=0){ perror("The Hive Cluster is under attcked"); exit(EXIT_FAILURE); } } pthread_barrier_destroy(&barrier); if(time == 0 || time == max_t-1){ if(flags[3]==1) print_all(num_astr, astr, time); if(flags[4]==1) print_c(num_astr, astr, time); if(flags[5]==1) print_q(num_thread, targv,time); } } return 0; }
int main(){ initShell(); initProcessList(); while(1){ prompt(); //substituir por variavel - para mostra o diretorio que esta newProcess = (Process_Object *)malloc(sizeof(Process_Object)); parser(); runProcess(newProcess); //resetAttributes(); } }
void _servosCenter(SERVO_LIST* const servos, uint8_t numServos, UART* uart){ rprintfInit(uart->writer); list(servos,numServos); help(); prompt(); while(1){ char c = getCh(uart); switch(c){ case 'L': list(servos,numServos); prompt(); break; case '+': update(servos,1); break; case '*': update(servos,10); break; case '-': update(servos,-1); break; case '/': update(servos,-10); break; case 'N': current = (current+1) % numServos; prompt(); break; case 'P': current = (current==0) ? numServos-1 : current-1; prompt(); break; case 'C': setRanging(FALSE, servos,numServos); prompt(); break; case 'R': setRanging(TRUE, servos,numServos); prompt(); break; default: help(); prompt(); break; } } }
void * shell(void *arg) { Client *C = arg; char input[INPUTSIZE]; int rc; int menu=1; //the following is done in order to change the prompt for the user to X or O while (1) { // Clear input each time bzero(&input, INPUTSIZE); prompt(menu, input); if (strlen(input)>0) { rc=docmd(C, input); menu = 1; } if (rc<0) { killConnection(C->ph); break; } if (rc==1) { menu=1; // Proto_Game_State *gs = proto_client_game_state(C->ph); } if (((Proto_Client *) C->ph)->game.status == IN_PROGRESS && DISPLAYUI == 1) { // launchUI(C); return NULL; } else menu=1; } if (PROTO_PRINT_DUMPS==1) fprintf(stderr, "terminating\n"); fflush(stdout); return NULL; }
char display_internal_slots( dtslot_t *slot, int8 *stbl, int8 nextindex, int32 *changed) { int32 i; idtentry_t *entry; int64 node_address; char result; int32 slot_number; for (i = 0; i < nextindex; i++) { slot_number = stbl[i]; entry = (idtentry_t *)&(slot[slot_number]); node_address = addressPXD(&(entry->xd)); printf("stbl[%d] = %d\n", i, slot_number); printf("[1] xd.len\t 0x%06x\t\t", entry->xd.len); printf("[4] next\t%d\n", entry->next); printf("[2] xd.addr1\t 0x%02x\t\t\t", entry->xd.addr1); printf("[5] namlen\t%d\n", entry->namlen); printf("[3] xd.addr2\t 0x%08x\t\t", entry->xd.addr2); printf(" xd.addr\t%lld\n", node_address); #ifdef _JFS_UNICODE printf("[6] name\t%.11ls\n", entry->name); #else printf("[6] name\t%.22s\n", entry->name); #endif printf("addressPXD(xd)\t%lld\n", node_address); result = prompt("dtree: press enter for next or [u]p, [d]own or e[x]it > "); if (result == 'x' || result == 'u' ) return result; else if (result != 'd' && entry->next >= 0) { result = display_slot(slot, entry->next, 0, changed); if (result == 'x' || result == 'u' ) return result; } if (result == 'd') /* descend to the child node */ return(display_extent_page(node_address)); } return result; }
void sp_process() { char c; while((c = serialRead()) != -1) { if((char_counter > 0) && ((c == '\n') || (c == '\r'))) { // Line is complete. Then execute! line[char_counter] = 0; // treminate string status_message(gc_execute_line(line)); char_counter = 0; // reset line buffer index prompt(); } else if (c <= ' ') { // Throw away whitepace and control characters } else if (c >= 'a' && c <= 'z') { // Upcase lowercase line[char_counter++] = c-'a'+'A'; } else { line[char_counter++] = c; } } }
main() { putenv("_=productivity"); chdir(getenv("HOME")); getparms(0); open_all(); while(1) { prompt(); /* get parameters */ if (!store_all()) continue; /* get all data */ print_prompt(); /* show or print data */ } } /*end of main */
/* return when user indicates exit */ void interact() { int i; char buf[MAX_CMD]; char *cmd; while (1) { prompt(); /* read command */ for (i=0; i<MAX_CMD; i++) buf[i] = '\0'; fgets(buf,MAX_CMD,stdin); cmd = trim(buf); /* process command */ /* (returns true when cmd indicates exit) */ if (process_command(cmd)) return; } }
void KReplaceDialog::slotButtonClicked( int button ) { if( button != KDialog::Ok ) KAbstractFindDialog::slotButtonClicked( button ); else { hide(); rememberCurrentSettings(); mTool->setSearchData( data() ); mTool->setReplaceData( replaceData() ); mTool->setCaseSensitivity( caseSensitivity() ); mTool->setDoPrompt( prompt() ); mTool->replace( direction(), fromCursor(), inSelection() ); } }
void console_tick(void) { switch(console_mode) { case CONSOLE_MODE_LINE: if (got_line) { if (cmdbuf_len > 0) execute_command_line(cmdbuf, cmdbuf_len); cmdbuf_len = 0; prompt(); got_line = FALSE; } break; default: break; } }
static int check_data (u8 *buf, unsigned length, unsigned seed) { unsigned i; u8 x; srandom(seed); for (i = 0; i < length; i++) { x = random(); if (buf[i] != x) { weprintf("check failed at %d %x!=%x\n", i, buf[i], x); prompt("failure:"); return FALSE; } } return TRUE; }
int main(void) { void * stack; double result; char type; char op; stack = initialize_stack(SIZE_INIT_STACK); /* check stack */ do { prompt(); type = gettype(); if(type == UNKNOWN) { printf("Valid FUNCTIONS NUMBERS OR %s", FUNCTIONS); return 0; } if(type == EXIT) return 0; if(type == NUMBER) push(atof(getop())); if(type == OPERAND) { if(!length_stack()) { printf("empty stack\n"); continue; } result = calc(); printf("\noutput%s%lf\n", PROMPT_SYMBOL, result); push(result); } } while(type != EXIT); return 0; }
////=========================================================================================== int main() { /* installation du handler pour le signal child_signal */ struct sigaction sig; sig.sa_flags = 0; sig.sa_handler = child_signal; sigemptyset(&sig.sa_mask); sigaction(child_signal,&sig,NULL); /* désactivation l'interruption par Contrôle+C */ sig.sa_handler = SIG_IGN; sigaction(SIGINT, &sig, NULL); initialize_readline (); using_history (); printf("Lecture de fichier d'histoire : (%s)\n",strerror(read_history (history_filename))); while (!Exit) { init(); prompt(); next=0; lire(); decoupe_ligne_seq(); int i=0; for (;i<numcmd_seq;i++) { char *line; char* elem[MAXELEMS]; //strcpy(&line,cmds_seq[i]); decoupe_ligne_pipe(cmds_seq[i]); if (piped) { runPipe(); } else { decoupe_cmd(cmds_seq[i],elem); if (redirected) { runRedirectedCommand(elem,red_file,red_type); } else { execute(elem); } } } } printf("Sauvegarde de fichier d'histoire : (%s)\n",strerror(write_history(history_filename))); return 0; }
int main (int argc, char *argv[]) { msg_s msg; ki_t key; int c; int rc; setprogname(argv[0]); while ((c = getopt(argc, argv, "i")) != -1) { switch (c) { case 'i': ignore_prompt(); break; default: usage(); break; } } prompt("start"); if (init_msg_tau(getprogname())) { exit(2); } prompt("sw_register"); sw_register(argv[0]); prompt("create_gate_tau"); key = make_gate(0, REQUEST | PASS_OTHER); prompt("sw_request"); rc = sw_request("pong", key); if (rc) failure("sw_request", rc); for (;;) { prompt("receive_tau"); rc = receive_tau( &msg); if (rc) failure("receive", rc); if (msg.q.q_tag) { key = (unsigned long)msg.q.q_tag; } else { key = msg.q.q_passed_key; } msg.q.q_passed_key = make_gate((void *)(unsigned long)key, REPLY); prompt("send_key_tau"); rc = send_key_tau(key, &msg); if (rc) failure("send_key_tau", rc); } }