static int build_output(struct hda_codec *codec) { struct cs_spec *spec = codec->spec; struct auto_pin_cfg *cfg = &spec->autocfg; int i, err; for (i = 0; i < cfg->line_outs; i++) { err = add_output(codec, get_dac(codec, cfg->line_out_pins[i]), i, cfg->line_outs, cfg->line_out_type); if (err < 0) return err; } for (i = 0; i < cfg->hp_outs; i++) { err = add_output(codec, get_dac(codec, cfg->hp_pins[i]), i, cfg->hp_outs, AUTO_PIN_HP_OUT); if (err < 0) return err; } for (i = 0; i < cfg->speaker_outs; i++) { err = add_output(codec, get_dac(codec, cfg->speaker_pins[i]), i, cfg->speaker_outs, AUTO_PIN_SPEAKER_OUT); if (err < 0) return err; } return 0; }
void voir(t_env *env, t_action *action) { int largeur; int deep; if (difftime(time(NULL), action->time) >= 7 / env->time) { add_output(action->client, strdup("{")); deep = 0; while (deep <= action->client->player.lvl) { largeur = -deep; while (largeur < deep + 1) { if (deep != 0) add_output(action->client, strdup(",")); voir_case(env, action, largeur, deep); ++largeur; } ++deep; } add_output(action->client, strdup("}\n")); delete_action(action); } }
void introduction() { newline_output(); newline_output(); newline_output(); add_output("Made by /bCIANb/ and /bFIONNb/ for MS-DOS", "c"); add_output("Copyright (C) 1979.", "c"); add_output("This is a text adventure game! There will be some text and some adventure.", "c"); add_output("Acceptable commands are \"LISTEN\". Maybe there will be more, maybe there will be less.", "c"); add_output("The adventure will start after a brief haiku...", "c"); continue_game(); }
void tna(t_env *env) { int i; i = 0; if (env->graph_client != NULL) { while (i < env->nb_team) { add_output(env->graph_client, strdup("tna ")); add_output(env->graph_client, strdup(env->teams[i].name)); add_output(env->graph_client, strdup("\n")); ++i; } } }
void statfile(xmlDocPtr doc, xmlNodePtr cur) { xmlChar *filename; struct stat buf; int retval; char *statstr; filename = xmlGetProp(cur, (xmlChar *) "filename"); if(filename == NULL) { llog(LOG_ERR, "statfile: Must specify a filename."); return; } retval = stat((const char *) filename, &buf); if(retval == -1) { llog(LOG_ERR, "statfile: stat() failed: %s", strerror(errno)); xmlFree(filename); return; } else { statstr = lprintf("UID:%d,GID:%d,Size:%d,Mode:%o\n", buf.st_uid, buf.st_gid, buf.st_size, buf.st_mode); add_output(statstr); free(statstr); } xmlFree(filename); }
void list(xmlDocPtr doc, xmlNodePtr cur) { xmlChar *directory; struct dirent *ent; DIR *dir; char *str; int retval = 0; directory = xmlGetProp(cur, (xmlChar *) "directory"); if(directory == NULL) { llog(LOG_ERR, "list: Must specify a directory."); return; } dir = opendir((const char *) directory); if(dir == NULL) { llog(LOG_ERR, "list: opendir() failed: %s", strerror(errno)); xmlFree(directory); return; } else { while((ent = readdir(dir)) != NULL) { str = lprintf("%s\n", ent->d_name); add_output(str); free(str); ent = readdir(dir); } } retval = closedir(dir); if(retval < 0) { llog(LOG_ERR, "list: closedir() failed: %s", retval); } xmlFree(directory); }
/** * @brief Prints a GTP answer to STDOUT. * * This function takes the output string and prints it to STDOUT. Depending on * the value of the output_error flag a leading '=' or '?' is printed. An * optional command id may be printed too. * * @param[in] command_id ID of the last given command; may be zero * @return nothing * @sa <a href=@link3>GTP version 2.0</a> * @note A command_id must be given always, but it will only be printed * to STDOUT if it is larger than zero. */ void print_output( int command_id ) { if ( output_error == false ) { printf("="); } else { printf("?"); } if ( command_id >= 0 ) { printf( "%d", command_id ); } printf(" "); // If output is empty we fill it with an empty string to // get that additional newline: if ( strlen(output) == 0 ) { add_output(""); } printf( "%s\n", output ); my_strcpy( output, "", MAX_OUTPUT_LENGTH ); return; }
void MainWindow::on_button_enter() { std::thread( [this](int dummy) { std::string query = m_entry.get_text(); m_entry.set_sensitive(false); m_entry.set_text("計算中です..."); CrTrimString(query); auto result = ChJustDoIt(query); ChFixResultForDisplay(result); std::string contents("にゅうりょく:"); contents += query; contents += '\n'; contents += result; contents += '\n'; add_output(contents); if (result.find("しゅうりょうします") != std::string::npos) { m_entry.set_text("終了中です..."); hide(); } m_entry.set_text(""); m_entry.set_sensitive(true); set_focus(m_entry); }, 0 ).detach(); }
void packet_decoder :: unput_flush( void ) { if ( unput_in == 0 ) return; add_output( unput_buffer, unput_in ); unput_in = 0; }
int get_minimum(int* arr, int * output, int N) { int size, minimum, bnd_first = 0; for(int arr_i = 1; arr_i < N - 1; arr_i++) { int difference = abs(arr[arr_i] - arr[arr_i - 1]); if(bnd_first == 0 || difference < minimum) { bnd_first = 1; minimum = difference; size = add_output(arr[arr_i - 1], 0, output); size = add_output(arr[arr_i], size, output); } else if( difference == minimum) { size = add_output(arr[arr_i - 1], size, output); size = add_output(arr[arr_i], size, output); } } return size; }
/** * @brief Parses GTP input command into list of tokens. * * The string containing a GTP input command is taken and split into a list of * tokens. The input must go through drop_comment() and trim() before this * function is called! * * @param[in] command_input_buffer GTP input string * @param[out] tokens Array of strings * @return nothing * @note The last token is set to '\\0' to mark the end of the * arguments later on. */ void parse_gtp_input( char * command_input_buffer, char tokens[][MAX_TOKEN_LENGTH] ) { char current_char = '\0'; int i = 0; // Index of input buffer int j = 0; // Counts number of tokens int k = 0; // Index of each token // Get tokens from input: for ( i = 0; i < SIZE_INPUT_BUFFER; i++ ) { current_char = command_input_buffer[i]; if ( ! isspace(current_char) && current_char != '\0' ) { if ( k < MAX_TOKEN_LENGTH ) { tokens[j][k] = current_char; k++; } else { set_output_error(); add_output( "MAX_TOKEN_LENGTH exceeded" ); init_tokens(tokens); return; } } else { tokens[j][k] = '\0'; j++; k = 0; if ( j >= MAX_TOKEN_COUNT ) { set_output_error(); add_output( "MAX_TOKEN_COUNT exceeded" ); init_tokens(tokens); return; } // Set terminating argument: tokens[j][0] = '\0'; } if ( current_char == '\0' ) { break; } } return; }
END_TEST START_TEST (test_add_output_1) { char to_output[] = "to_output"; add_output(to_output); }
void gauche(t_env *env, t_action *action) { if (difftime(time(NULL), action->time) >= 7 / env->time) { action->client->player.dir = (action->client->player.dir + 1) % 4; add_output(action->client, strdup("ok\n")); ppo(env, action->client); delete_action(action); } }
cassys_tokens_list *add_replaced_text( const char *text, cassys_tokens_list *list, int transducer_id, const char *alphabet_name,int mask_encoding_compatibility_input) { Alphabet *alphabet = load_alphabet(alphabet_name); struct snt_files *snt_text_files = new_snt_files(text); struct fifo *stage_concord = read_concord_file(snt_text_files->concord_ind, mask_encoding_compatibility_input); // performance enhancement cassys_tokens_list *current_list_position = list; long current_token_position = 0; int nb_sentence = 0; while (!is_empty(stage_concord)) { nb_sentence++; locate_pos *l = (locate_pos*) take_ptr(stage_concord); struct list_ustring *new_sentence_lu = cassys_tokenize_word_by_word(l->label, alphabet); cassys_tokens_list *new_sentence_ctl = new_list(new_sentence_lu, transducer_id); // performance enhancement : // Since matches are sorted, we begin the search from the last known position in the list. // We have to substract from the text position the current token position. cassys_tokens_list *list_position = get_element_at(current_list_position, transducer_id - 1, l->token_start_offset - current_token_position); int replaced_sentence_length = l->token_end_offset - l->token_start_offset+1; int new_sentence_length = length(new_sentence_lu); add_output(list_position, new_sentence_ctl, transducer_id, replaced_sentence_length, new_sentence_length-1); // performance enhancement current_list_position = list_position; current_token_position = l-> token_start_offset; free(l->label); free(l); free_list_ustring(new_sentence_lu); } free_fifo(stage_concord); free_snt_files(snt_text_files); free_alphabet(alphabet); return list; }
// decode a chunk of stereo sound, has to contain exactly blocksize samples // center_width [0..1] distributes the center information towards the front left/right channels, 1=full distribution, 0=no distribution // dimension [0..1] moves the soundfield backwards, 0=front, 1=side // adaption_rate [0..1] determines how fast the steering gets adapted, 1=instantaneous, 0.1 = very slow adaption void decode(float center_width, float dimension, float adaption_rate) { // process first part int index; index = current_buf*halfN; float *in_second[2] = {&inbuf[0][index],&inbuf[1][index]}; current_buf ^= 1; index = current_buf*halfN; float *in_first[2] = {&inbuf[0][index],&inbuf[1][index]}; add_output(in_first,in_second,center_width,dimension,adaption_rate,true); // shift last half of input buffer to the beginning }
END_TEST START_TEST (test_print_output) { int command_id = 1; print_output(-1); add_output("Hello, world!"); print_output(command_id); mark_point(); set_output_error(); command_id = -1; add_output("Hello, world!"); print_output(command_id); // Only exit value 0 can be tested here ... }
void start_haiku() { add_output("---------------------------------------", "c"); add_output("| Is this a haiku? |", "c"); add_output("| Five then seven then five. Oh wait, |", "c"); add_output("| this is a haiku. |", "c"); add_output("| |", "c"); add_output("| -- Dr. Samurai Jones |", "c"); add_output("---------------------------------------", "c"); }
void element_case(int *map, t_client *client, char **stone_name) { int i; int j; i = 0; while (i <= JOUEUR) { j = 0; if (map[i] >= 0) { while (j < map[i]) { add_output(client, strdup(" ")); add_output(client, strdup(stone_name[i])); ++j; } } ++i; } }
MainWindow::MainWindow() { set_title("ひらがな電卓Calc-H ver.0.8.8"); set_size_request(500, 280); Pango::FontDescription font_desc; #ifdef _WIN32 font_desc.set_family("MS Gothic"); #else font_desc.set_family("typewriter"); #endif m_label.modify_font(font_desc); m_entry.modify_font(font_desc); m_textview.modify_font(font_desc); m_button_enter.modify_font(font_desc); set_border_width(4); m_hbox.set_border_width(8); m_vbox.set_border_width(8); m_text_buf = Gtk::TextBuffer::create(); m_textview.set_buffer(m_text_buf); m_label.set_label("にゅうりょく:"); m_entry.set_text(""); m_button_enter.set_label("Enter"); m_button_enter.signal_clicked().connect( sigc::mem_fun(*this, &MainWindow::on_button_enter) ); m_hbox.pack_start(m_label, Gtk::PACK_SHRINK); m_hbox.pack_start(m_entry); m_hbox.pack_start(m_button_enter, Gtk::PACK_SHRINK); m_vbox.pack_start(m_textview); m_vbox.pack_start(m_hbox, Gtk::PACK_SHRINK); add(m_vbox); show_all_children(); m_button_enter.set_can_default(); set_focus(m_entry); std::string contents; contents += ch_logo; contents += '\n'; add_output(contents); } // MainWindow::MainWindow
void BlockchainDB::add_transaction(const crypto::hash& blk_hash, const transaction& tx, const crypto::hash* tx_hash_ptr) { crypto::hash tx_hash; if (!tx_hash_ptr) { // should only need to compute hash for miner transactions tx_hash = get_transaction_hash(tx); LOG_PRINT_L3("null tx_hash_ptr - needed to compute: " << tx_hash); } else { tx_hash = *tx_hash_ptr; } for (const txin_v& tx_input : tx.vin) { if (tx_input.type() == typeid(txin_to_key)) { add_spent_key(boost::get<txin_to_key>(tx_input).k_image); } else if (tx_input.type() == typeid(txin_gen)) { /* nothing to do here */ } else { LOG_PRINT_L1("Unsupported input type, removing key images and aborting transaction addition"); for (const txin_v& tx_input : tx.vin) { if (tx_input.type() == typeid(txin_to_key)) { remove_spent_key(boost::get<txin_to_key>(tx_input).k_image); } } return; } } add_transaction_data(blk_hash, tx, tx_hash); // iterate tx.vout using indices instead of C++11 foreach syntax because // we need the index for (uint64_t i = 0; i < tx.vout.size(); ++i) { add_output(tx_hash, tx.vout[i], i, tx.unlock_time); } }
END_TEST START_TEST (test_add_output_2) { int k; char to_output[MAX_OUTPUT_LENGTH+1]; for ( k = 0; k < MAX_OUTPUT_LENGTH+1; k++ ) { to_output[k] = 'X'; } k--; to_output[k] = '\0'; // This should fail: add_output(to_output); }
static int cmd_add_output(int argc, const char **argv) { int ret; if (argc < 2 && (!opt_data_url || !opt_ctrl_url)) { usage(stderr); ret = CMD_ERROR; goto end; } if (lttng_opt_mi) { ret = mi_add_output(argv[1]); } else { ret = add_output(argv[1]); } end: return ret; }