void send_file(void) { const char *file; FILE *f; char buf[BUFSIZ], *expanded; size_t len; file = get_input("Local file?"); if (file == NULL || *file == '\0') return; expanded = tilde_expand(file); f = fopen(expanded, "r"); if (f == NULL) { cu_warn("%s", file); return; } while (!feof(f) && !ferror(f)) { len = fread(buf, 1, sizeof(buf), f); if (len != 0) bufferevent_write(line_ev, buf, len); } fclose(f); free(expanded); }
int main (int argc, char *argv[]) { class B b; if (middleman (b, get_input ()) != 3) abort (); return 0; }
/* Requirement 5 - handle the logic for each individual move */ enum move_result player_move(enum cell_contents board[][BOARD_WIDTH]) { char input[INPUT_LENGTH]; struct move move; enum move_validity move_validity; while (TRUE) { display_board(board); printf("\nPlease enter a move [enter Q or ctrl-D to quit]: "); /* quit conditions */ if (get_input(input) == NULL) return QUIT_GAME; else if (strlen(input) == 1 && toupper(input[0]) == 'Q') return QUIT_GAME; move_validity = try_get_move(&move, input, board); if (move_validity == VALID) { perform_move(move, board); return SUCCESSFUL_MOVE; } else print_move_validity_string(move_validity); } return SUCCESSFUL_MOVE; }
int main(void){ int x = get_input(); int y = compute(x); print_output(y); return 0; }
int main(){ //getting user input int recpNum = get_input(); float crntRcp[6]; //decoding the recipe switch(recpNum){ case 1: eeprom_read_block((void*)&crntRcp, (const void*)&curry1, 24); break; case 2: eeprom_read_block((void*)&crntRcp, (const void*)&curry2, 24); break; case 3: eeprom_read_block((void*)&crntRcp, (const void*)&curry3, 24); break; case 4: eeprom_read_block((void*)&crntRcp, (const void*)&curry4, 24); break; } return 0; }
int main(void) { int i, j; int status; char ch, excess_ch; while (get_input(&ch, &i, &j, &status)) { excess_ch = getchar(); if (excess_ch != '\n') { if (status == 2) { printf("Too many inputs.\n"); } else { printf("Invalid input.\n"); } while (getchar() != '\n'); continue; } chline(ch, i, j); } printf("\nBye!\n"); return 0; }
int main(int argc, char** argv) { assert(argc > 1); int x; printf("address in stack: %p\n", &x); user_data_arr[0] = (char*) malloc(DATA_SZ); assert(user_data_arr[0]); uint64_t* program_data_ptr = (uint64_t*) malloc(DATA_SZ); assert(program_data_ptr); int i; for (i = 0; i < argc-1; i++) { int sz = get_input(argv[i+1], user_input); int j; char* arr = user_data_arr[0]; for (j = 0; j < sz; j++) { arr[j] = user_input[j]; } if (i == 0) { free(program_data_ptr); } } return 0; }
int main() { char input_string[max]; get_input(input_string); reverse(input_string); printf("\n"); skip(input_string); return 0; }
/* stdio functions */ static int GSDLLCALL gsdll_stdin(void *instance, char *buf, int len) { if (isatty(fileno(stdin))) return get_input(buf, len); else return fread(buf, 1, len, stdin); }
int main(void) { get_input(); solve(); save_output(); return 0; }
int main() { std::string line; std::getline(std::cin, line); std::istringstream istr(line); get_input(istr); return 0; }
static inline int readsync() { _bptr=0; _buffer[0]=_buffer[1]; _buffer[1]=_buffer[2]; _buffer[2]=_buffer[3]; return get_input(&_buffer[3],1); }
void gameloop(MemCardView* view) { while (true) { if (!get_input()) break; update(view); draw(view); calculateFPS(); } }
int main (int argc, int *argv[]) { int i; for (i = 0; i < get_input (); i++) hiphip (hooray); return 0; }
char retry_or_quit(void) { char *c; do { cprintf("\r\nr)etry or q)uit?\r\n"); c = get_input(); } while ((*c != 'r') && (*c != 'q')); return *c; }
int main (int argc, char *argv[]) { int i = 0; while (i < 1000) i += docalling (get_input (), &String::funcOne); non_existent ("done", i); return 0; }
int main() { char a[50]; get_input(a); puts(a); }
void process_player_input(node *player, stats *status){ u8 decision; u16 rise; if(player->state != FOLD){ //decision = get_player_decision1(player->number); decision = get_input(win.commands); u8 number_of_tries = 0; // number of tries while( decision < 1 || decision > 3 ){ if(number_of_tries <10){ display_message(player->number, "Try again!\n"); //decision = get_player_decision1(player->number); decision = get_input(win.commands); } else{ // If input was incorrect too many times default to FOLD decision = FOLD; break; } } if(decision == FOLD){ player->state = FOLD; status->folded--; } else if(decision == CALL){ dealer(player, status->money_to_play); player->state = CALL; } else if(decision == RISE){ rise = get_player_decision2(player->number, "Player raised\n"); while(rise <= 0){ // Make sure rise is not equal or less than 0 rise = get_player_decision2(player->number, "Invalid value, must be above 0\n"); } status->money_to_play += rise; dealer(player, status->money_to_play); status->last = player; // Update last player to the one that rised! player->state = RISE; } } }
int main() { double n1 = get_input(); double n2 = get_input(); double value; int i; for (i = 0; i < 5; i++) { value = get_next(n2, n1); n2 = n1; n1 = value; } print_result(value); return 1; }
static char * command_line_input(const char *prompt) { if (instream == stdin) return get_input(prompt); /* Reading from init or command file; no prompting or history */ return basic_get_input(NULL); }
bool prompt_menu(const char *prompt, const struct menu_item *items, int *selected) { enum input_status status = INPUT_OK; struct key key; int size = 0; while (items[size].text) size++; assert(size > 0); while (status == INPUT_OK) { const struct menu_item *item = &items[*selected]; char hotkey[] = { '[', (char) item->hotkey, ']', ' ', 0 }; int i; update_status("%s (%d of %d) %s%s", prompt, *selected + 1, size, item->hotkey ? hotkey : "", item->text); switch (get_input(COLS - 1, &key, FALSE)) { case KEY_RETURN: case KEY_ENTER: case '\n': status = INPUT_STOP; break; case KEY_LEFT: case KEY_UP: *selected = *selected - 1; if (*selected < 0) *selected = size - 1; break; case KEY_RIGHT: case KEY_DOWN: *selected = (*selected + 1) % size; break; case KEY_ESC: status = INPUT_CANCEL; break; default: for (i = 0; items[i].text; i++) if (items[i].hotkey == key.data.bytes[0]) { *selected = i; status = INPUT_STOP; break; } } } report_clear(); return status != INPUT_CANCEL; }
int main (int argc, char *argv[]) { class C c; if (middleman (&c, get_input ()) != 4) abort (); return 0; }
int main (int argc, char *argv[]) { int n = get_input(); int matrix[n][n]; init_matrix(n, matrix); int sum = matrix_sum(n, matrix); printf("%d", sum); return 0; }
int main (int argc, char *argv[]) { int i, j = get_input (); for (i = 0; i < j; i++) if ((middleman (&b, j) + 100 * middleman (&b.confusion, j)) != 203) abort (); return 0; }
int main() { int res, Wval; bool NVWrite, WPotA; unsigned rval=0; CParaSpi spi; //create SPI object printf("Digital Pot SPI Example\n"); printf("Initializing object...\n"); spi.SetMode(1, 1, 0); //(nCPOL, nCPHA, nEPOL) Set the proper SPI mode for the digital pot res = spi.AssignPins(57, 55, 56, 54); //(nCLK, nMOSI, nMISO, nSS) //nCPOL = Idle Clock Polarity (1 or 0) nCPHA = Clock Phase (0=first edge 1=second edge) nEPOL= Slave Enable Polarity (1 or 0) if(res) { fprintf(stderr, "spi.AssignPins returned %d", res); exit(1); } if(!spi.IsOK()) { fprintf(stderr, "SPI Object creation failed, exiting\n"); exit(1); } printf("Success\n"); while(1) { res = get_input(&WPotA, &NVWrite, &Wval); if(res) break; if (WPotA) { Wval = Wval + 0x100; //add the write hex value if writing to pot A } else Wval = Wval + 0x200 ; //add the write hex value if writing to pot B if (NVWrite) Wval = Wval + 0x1000; //if writing to EEPROM, add correct hex value to the two byte message res = spi.Xfer(16, (unsigned int)Wval, &rval); //transfer the message (16 bits/2 bytes) if(res) { fprintf(stderr, "Xfer() returned %d, exiting\n", res); //print what was sent return res; } printf("Sent 0x%08X, Rcvd 0x%08X\n\n", Wval, rval); //print what was recieved back } // done: printf("Closing\n"); spi.Close(); //close the connection return 0; }
static __attribute__ ((noinline)) void bah () { class B b; C *c = new ((void *) &b.data) C; if (middleman (&b, get_input ()) != 3) abort (); }
/** * Asks for user input repeatedly until a valid number is entered. */ int get_user_choice() { int user_choice = 0; do printf("Make your choice, knave! "); while (sscanf(get_input(), "%d", &user_choice) != 1); return user_choice; }
int main(int argc, char** argv) { if (check_commandline_args(argc, argv) >= 0) { get_input(0); } return 0; }
void run_cmdline_loop(repl_t *repl, JSContextRef ctx) { while (true) { char *input_line = NULL; if (config.dumb_terminal) { display_prompt(repl->current_prompt); input_line = get_input(); if (input_line == NULL) { // Ctrl-D pressed printf("\n"); break; } } else { // Handle prints while processing linenoise input if (cljs_engine_ready) { cljs_set_print_sender(ctx, &linenoisePrintNow); } // If *print-newline* is off, we need to emit a newline now, otherwise // the linenoise prompt and line editing will overwrite any printed // output on the current line. if (cljs_engine_ready && !cljs_print_newline(ctx)) { fprintf(stdout, "\n"); } char *line = linenoise(repl->current_prompt, prompt_ansi_code_for_theme(config.theme), repl->indent_space_count); // Reset printing handler back if (cljs_engine_ready) { cljs_set_print_sender(ctx, NULL); } repl->indent_space_count = 0; if (line == NULL) { if (errno == EAGAIN) { // Ctrl-C errno = 0; repl->input = NULL; empty_previous_lines(repl); repl->current_prompt = form_prompt(repl->current_ns, false); printf("\n"); continue; } else { // Ctrl-D exit_value = EXIT_SUCCESS_INTERNAL; break; } } input_line = line; } bool break_out = process_line(repl, ctx, input_line); if (break_out) { break; } } }
void contractor_ibex_fwdbwd::prune(contractor_status & cs) { DREAL_LOG_DEBUG << "contractor_ibex_fwdbwd::prune"; auto ctc = get_ctc(std::this_thread::get_id(), true); if (!ctc) { return; } DREAL_THREAD_LOCAL static box old_box(cs.m_box); if (cs.m_config.nra_proof) { old_box = cs.m_box; } if (m_numctr->f.nb_arg() == 0) { auto eval_result = m_ctr->eval(cs.m_box); if (eval_result.first == l_False) { cs.m_box.set_empty(); return; } else { return; } } DREAL_THREAD_LOCAL static ibex::IntervalVector old_iv(cs.m_box.get_values()); old_iv = cs.m_box.get_values(); assert(m_numctr->f.nb_arg() >= 0 && static_cast<unsigned>(m_numctr->f.nb_arg()) <= cs.m_box.size()); DREAL_LOG_DEBUG << "Before pruning using ibex_fwdbwd(" << *m_numctr << ")"; DREAL_LOG_DEBUG << cs.m_box; DREAL_LOG_DEBUG << "ibex interval = " << cs.m_box.get_values() << " (before)"; DREAL_LOG_DEBUG << "function = " << ctc->f; DREAL_LOG_DEBUG << "domain = " << ctc->d; ctc->contract(cs.m_box.get_values()); DREAL_LOG_DEBUG << "ibex interval = " << cs.m_box.get_values() << " (after)"; // cerr << output.empty() << used_constraints.empty() << " "; auto & new_iv = cs.m_box.get_values(); bool changed = false; for (unsigned i = 0; i < cs.m_box.size(); ++i) { if (get_input().contain(i) && old_iv[i] != new_iv[i]) { cs.m_output.add(i); changed = true; } } if (changed || cs.m_box.is_empty()) { // only add used_constraints if there is any change cs.m_used_constraints.insert(m_ctr); } DREAL_LOG_DEBUG << "After pruning using ibex_fwdbwd(" << *m_numctr << ")"; DREAL_LOG_DEBUG << cs.m_box; if (cs.m_config.nra_proof) { // ======= Proof ======= DREAL_THREAD_LOCAL static ostringstream ss; Enode const * const e = m_ctr->get_enode(); ss << (e->getPolarity() == l_False ? "!" : "") << e; output_pruning_step(old_box, cs, ss.str()); ss.str(string()); } return; }