void ignore_last_nick(char dumb, char *dumber) { NickTab *nick; char *tmp1; if ((nick = gettabkey(1, NULL))) { set_input(empty_str); tmp1 = m_sprintf("%sig %s", get_string_var(CMDCHARS_VAR), nick->nick); set_input(tmp1); new_free(&tmp1); } update_input(UPDATE_ALL); }
void for_loop_fix_state_input(Branch* contents) { // This function will look at the state access inside for-loop contents. // If there's state, the default building functions will have created // terms that look like this: // // input() :state -> unpack_state -> pack_state -> output() :state // // We want each loop iteration to have its own state container. So we'll // insert pack/unpack_state_list_n terms so that each iteration accesses // state from a list. The result will look like: // // input() :state -> unpack_state_list_n(index) -> unpack_state -> pack_state // -> pack_state_list_n(index) -> output() :state // First insert the unpack_state_list_n call Term* stateInput = find_state_input(contents); // Nothing to do if there's no state input if (stateInput == NULL) return; // Nothing to do if unpack_state_list_n term already exists if (find_user_with_function(stateInput, FUNCS.unpack_state_list_n) != NULL) return; Term* unpackState = find_user_with_function(stateInput, FUNCS.unpack_state); ca_assert(unpackState != NULL); Term* index = for_loop_find_index(contents); Term* unpackStateList = apply(contents, FUNCS.unpack_state_list_n, TermList(stateInput, index)); transfer_users(stateInput, unpackStateList); move_before(unpackStateList, unpackState); set_input(unpackState, 0, unpackStateList); // Now insert the pack_state_list_n call Term* stateResult = find_open_state_result(contents, contents->length()); Term* packStateList = apply(contents, FUNCS.pack_state_list_n, TermList(stateInput, stateResult, index)); packStateList->setBoolProp("final", true); move_after(packStateList, stateResult); // Make sure the state output uses this result Term* stateOutput = append_state_output(contents); set_input(stateOutput, 0, packStateList); }
void modify_branch_so_that_state_access_is_indexed(Branch* branch, int index) { Term* stateInput = find_state_input(branch); if (stateInput == NULL) return; // If the state output is connected directly to state input, then do nothing. Term* stateOutput = find_state_output(branch); if (stateOutput->input(0) == stateInput) return; Term* unpackList = apply(branch, FUNCS.unpack_state_from_list, TermList(stateInput)); unpackList->setIntProp("index", index); move_after_inputs(unpackList); for (int i=0; i < stateInput->users.length(); i++) { Term* term = stateInput->users[i]; if (term == unpackList) continue; remap_pointers_quick(term, stateInput, unpackList); } Term* stateResult = stateOutput->input(0); ca_assert(stateResult != NULL); Term* packList = apply(branch, FUNCS.pack_state_to_list, TermList(stateInput, stateResult)); packList->setIntProp("index", index); packList->setBoolProp("final", true); set_input(stateOutput, 0, packList); move_after(packList, stateResult); }
void if_block_create_input_placeholders_for_outer_pointers(Term* ifCall) { Branch* contents = nested_contents(ifCall); TermList outerTerms; // Find outer pointers across each case for (CaseIterator it(contents); it.unfinished(); it.advance()) { list_outer_pointers(nested_contents(it.current()), &outerTerms); } ca_assert(ifCall->numInputs() == 0); // Create input placeholders and add inputs for all outer pointers for (int i=0; i < outerTerms.length(); i++) { Term* outer = outerTerms[i]; set_input(ifCall, i, outer); Term* placeholder = append_input_placeholder(nested_contents(ifCall)); rename(placeholder, outer->name); // Go through each case and repoint to this new placeholder for (CaseIterator it(contents); it.unfinished(); it.advance()) { remap_pointers_quick(nested_contents(it.current()), outer, placeholder); } } }
static ErlDrvData tun_start(ErlDrvPort port, char *args) { struct tun_state *state; int fd; int mode; char dev_name[IFNAMSIZ]; state = (struct tun_state*) sys_alloc(sizeof(struct tun_state)); if (state == NULL) { errno = ENOMEM; /* appropriate to set errno? */ return ERL_DRV_ERROR_ERRNO; } if (!parse_args(args, &mode, state->dev, IFNAMSIZ - 1)) { return ERL_DRV_ERROR_BADARG; } fd = make_if(mode, state->dev); if (fd < 0) { return ERL_DRV_ERROR_GENERAL; } state->port = port; state->fd = fd; state->active = ACTIVE_FALSE; set_input(state, 0); return (ErlDrvData)state; }
static void tun_stop(ErlDrvData data) { struct tun_state *state = (struct tun_state *)data; set_input(state, 0); close(state->fd); sys_free(state); }
/* Compile an entire file of output from cpp, named NAME. Write a file of assembly output and various debugging dumps. */ static void compile_file(char *name) { FILE *ifile; #if !USE_CPPLIB /* Open input file. */ if (name == 0 || !strcmp (name, "-")) { ifile = stdin; name = "stdin"; } else ifile = fopen (name, "r"); if (ifile == 0) pfatal_with_name (name); #ifdef IO_BUFFER_SIZE setvbuf(ifile, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE); #endif #endif /* !USE_CPPLIB */ set_nomem_handler(outofmemory); set_input(ifile, name); init_lex(); /* needs to go before init_semantics, since inits dummy_location */ init_semantics(); if (yyparse () != 0) { if (errorcount == 0) fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)"); } fclose (ifile); if (errorcount == 0) { /*if (flag_parse_only) { fprintf(stderr, "\nDONE. Unparsing............\n\n"); unparse(stdout, the_program); } else exit(exec_cc1(the_program));*/ if (the_program) { parsed_file pf; pf = ralloc(parse_region, struct parsed_file); pf->name = name; pf->program = the_program; dd_add_last(parse_region, parsed_files, pf); analyze(the_program); } } }
bool hts_engine_call::execute() { set_input(); set_output(); engine_impl->synthesize(); return !output.is_stopped(); }
void insert_looped_placeholders(Block* contents) { Value names; list_names_that_must_be_looped(contents, &names); for (ListIterator it(&names); it; ++it) { Term* inputPlaceholder = append_input_placeholder(contents); Value* name = it.value(); rename(inputPlaceholder, name); Value owningTermVal; owningTermVal.set_term(contents->owningTerm); Term* outsideTerm = find_name_at(&owningTermVal, name); Term* innerResult = find_local_name(contents, name); Term* outputPlaceholder = append_output_placeholder(contents, innerResult); rename(outputPlaceholder, name); set_inputs(inputPlaceholder, TermList(outsideTerm, outputPlaceholder)); for (BlockInputIterator it(contents); it; ++it) { Term* term = it.currentTerm(); if (it.currentInput() == outsideTerm && term != inputPlaceholder) set_input(term, it.currentInputIndex(), inputPlaceholder); } } }
void nick_completion(char dumb, char *dumber) { char *q, *line; int i = -1; char *nick = NULL, *tmp; q = line = m_strdup(¤t_screen->input_buffer[MIN_POS]); if (in_completion == STATE_NORMAL) { i = word_count(line); nick = extract_words(line, i - 1, i); } if (nick) line[strlen(line) - strlen(nick)] = 0; else *line = 0; if ((tmp = getchannick(input_lastmsg, nick && *nick ? nick : NULL))) { malloc_strcat(&q, tmp); set_input(q); update_input(UPDATE_ALL); malloc_strcpy(&input_lastmsg, tmp); in_completion = STATE_COMPLETE; } new_free(&q); new_free(&nick); }
void CNeuralNetworkTest::process(u32 learn) { u32 j; set_input(); set_required_output(); neural_network->process(input); if (learn != 0) neural_network->learn(required_output); for (j = 0; j < output.size(); j++) output[j] = neural_network->get()[j]; error_now = 0.0; for (j = 0; j < output.size(); j++) { float tmp = (required_output[j] - output[j]); if (tmp < 0.0) tmp = -tmp; error_now+= tmp; } float k = 0.98; error_filtered = k*error_filtered + (1.0 - k)*error_now; error_total+= error_now; }
void repoint_terms_to_use_input_placeholders(Branch* contents) { // Visit every term for (int i=0; i < contents->length(); i++) { Term* term = contents->get(i); // Visit every input for (int inputIndex=0; inputIndex < term->numInputs(); inputIndex++) { Term* input = term->input(inputIndex); if (input == NULL) continue; // If the input is outside this branch, then see if we have a named // input that could be used instead. if (input->owningBranch == contents || input->name == "") continue; Term* replacement = find_input_placeholder_with_name(contents, input->name.c_str()); if (replacement == NULL) continue; set_input(term, inputIndex, replacement); } } }
Token :: Token(char input, Category category, double actual_value, int precedence) { set_input(input); set_category(category); set_actual_value(actual_value); set_precedence(precedence); }
// Main entry to the interpret. No tests will be launched, only // pure interpret will be compiled int main(int argc, char *argv[]) { int result; if ((result = check_params(argc, argv))) { return result; } // naalokujeme sdilenou datovou strukturu make_data_structure(); // otevrem soubor set_input(argv[1]); #ifdef LEX_TEST do { get_token(); } while (d->token->type != EOF); #else // parse parser_prepare(d); d = parser_run(); if (d->error != CODE_OK) { return 2; } InterpretInit(d->tree->d.list); // interpret the list InterpretRun(); #endif return 0; }
void Term::setDependency(int index, Term* term) { if (index == 0) change_function(this, term); else set_input(this, index - 1, term); }
void toggle_console(void* cp) { console c = cp; (void)c; if (main_console->active == 1) { hide_window(main_console->win); main_console->active = 0; set_input(NULL, 0); } else { show_window(main_console->win); main_console->active = 1; set_input(main_console->tb_in->data, 1000); } }
/* Configura as portas como inputs e outputs */ void init_ports (void){ /*Define as portas como saída*/ set_output(DDRB, PB1); //OC1A e PWM_B set_output(DDRB, PB2); //OC1B e PWM_A set_output(DDRB, PB5); //SCK e (RESET_AB)' set_output(DDRB, PB7); //(RESET_CD)' set_output(DDRD, PD5); //PWM_C set_output(DDRD, PD6); //PWM_D /*Define as portas como entrada*/ set_input(DDRB, PB3); //MOSI e (FALUT)' set_input(DDRB, PB4); //MISO e (OTW)' set_input(DDRC, PC6); //(RESET)' set_input(DDRD, PD2); //INT0 e CH1 set_input(DDRD, PD3); //INT1 e CH0 /*Portas PC0-PC3 podem ser usadas como sensores. Não foram implementadas*/ }
static int tun_ctl(ErlDrvData data, unsigned int cmd, char *buf, int len, char **rbuf, int rsize) { struct tun_state *state = (struct tun_state *)data; int read_len; switch (cmd) { case REQUEST_GET_DEVICE: return ctl_reply(REPLY_OK, state->dev, strlen(state->dev), rbuf, rsize); case REQUEST_ACTIVE: state->active = (int)*buf; switch (state->active) { case ACTIVE_FALSE: set_input(state, 0); break; case ACTIVE_TRUE: set_input(state, 1); break; case ACTIVE_ONCE: /* optimization: try to read a packet immediately if it exists, to avoid going back to select() */ read_len = read(state->fd, state->buf, TUNNEL_BUF_SIZE); if (read_len > 0) { /* got a packet */ driver_output(state->port, state->buf, read_len); state->active = ACTIVE_FALSE; set_input(state, 0); } else { /* no packet available yet */ set_input(state, 1); } break; default: assert(0); } return ctl_reply(REPLY_OK, "", 0, rbuf, rsize); default: return ctl_reply(REPLY_ERROR, "", 0, rbuf, rsize); } }
void loop_update_continue_inputs(Branch* branch, Term* continueTerm) { for (int i=0;; i++) { Term* output = get_output_placeholder(branch, i); if (output == NULL) break; set_input(continueTerm, i, find_intermediate_result_for_output(continueTerm, output)); } }
int main() { integ x = new_integ(sine); sleep(2); set_input(x, 0); usleep(500000); printf("%g\n", x->v); return 0; }
integ new_integ(double (*func)(double)) { integ x = malloc(sizeof(integ_t)); x->v = x->last_v = 0; x->func = 0; gettimeofday(&x->start, 0); set_input(x, func); pthread_create(&x->id, 0, tick, x); return x; }
void Term::setDependency(int index, Term* term) { if (index == 0) change_function(this, term); else if (index == 1) set_declared_type(this, unbox_type(term)); else set_input(this, index - 2, term); }
int set_cap_param_v4l2(struct video_device *vdev, int *palettes, int nb) { struct capture_device *c = vdev->capture; int ret = 0; int def[NB_SUPPORTED_PALETTE] = DEFAULT_PALETTE_ORDER; dprint(LIBVIDEO_SOURCE_CAP, LIBVIDEO_LOG_DEBUG, "CAP: Setting capture parameters on device %s.\n", vdev->file); if(nb<0 || nb>=NB_SUPPORTED_PALETTE) { dprint(LIBVIDEO_SOURCE_CAP, LIBVIDEO_LOG_ERR, "CAP: Incorrect number of palettes (%d)\n", nb); return LIBVIDEO_ERR_FORMAT; } if(nb==0 || palettes==NULL) { dprint(LIBVIDEO_SOURCE_CAP, LIBVIDEO_LOG_DEBUG, "CAP: No palettes supplied, trying default order.\n"); palettes = def; nb = NB_SUPPORTED_PALETTE; } //set desired standard if (set_std(c, vdev->fd) !=0 ) { ret = LIBVIDEO_ERR_STD; goto fail; } //set desired input if (set_input(c, vdev->fd) != 0) { ret = LIBVIDEO_ERR_CHANNEL; goto fail; } //Set image format if (set_image_format(c, palettes, nb, vdev->fd) != 0) { ret = LIBVIDEO_ERR_FORMAT; goto fail; } //Set crop format if (set_crop(c, vdev->fd) != 0) { info("Listing the reported capabilities:\n"); ret = LIBVIDEO_ERR_CROP; goto fail; } //set FPS set_param(c, vdev->fd); return ret; fail: info("Listing the reported capabilities:\n"); list_cap_v4l2(vdev->fd); return ret; }
void index_func_postCompile(Term* term) { Term* enclosingLoop = find_enclosing_for_loop(term); if (enclosingLoop == NULL) return; Term* loop_index = for_loop_find_index(nested_contents(enclosingLoop)); if (loop_index == NULL) return; set_input(term, 0, loop_index); set_input_hidden(term, 0, true); }
void phillip_main_t::learn(const lf::input_t &input) { auto get_path_for_gold = [this](const std::string &key) -> std::string { std::string path = param(key); if (not path.empty()) { int idx = path.rfind('.'); if (idx > 0) path = path.substr(0, idx) + ".gold" + path.substr(idx); else path += ".gold"; } return path; }; reset_for_inference(); set_input(input); auto begin = std::chrono::system_clock::now(); erase_flag("get_pseudo_positive"); execute_enumerator(); execute_convertor(); execute_solver(); set_flag("get_pseudo_positive"); execute_convertor( &m_ilp_gold, &m_time_for_convert_gold, get_path_for_gold("path_ilp_out")); execute_solver( &m_sol_gold, &m_time_for_solve_gold, get_path_for_gold("path_sol_out")); util::xml_element_t elem("learn", ""); m_ilp_convertor->tune(m_sol.front(), m_sol_gold.front(), &elem); m_time_for_learn = util::duration_time(begin); std::ofstream *fo(NULL); if ((fo = _open_file(param("path_out"), std::ios::out | std::ios::app)) != NULL) { if (not flag("omit_proof_graph_from_xml")) { m_sol.front().print_graph(fo); m_sol_gold.front().print_graph(fo); } elem.print(fo); delete fo; } }
/*!\brief Compute outputs of a network for given inputs. * \param net Pointer to a neural network. * \param input Pointer to sequence of floating point numbers. * \param output Pointer to sequence of floating point numbers or NULL. * * Compute outputs of a neural network for given inputs by forward * propagating the inputs through the layers. If output is non-NULL, the * outputs are copied to output (otherwise they are only stored * internally in the network). Note that the outputs of the neural * network will always lie in the interval (0,1); the caller will have to * rescale them if neccesary. */ void net_compute (network_t *net, const float *input, float *output) { assert (net != NULL); assert (input != NULL); set_input (net, input); forward_pass (net); if (output != NULL) { get_output (net, output); } }
inline void spi_slave_init (void) { // slave select, dmx channel select, ready to transmit (ok) line set_input(SPI_OUT_DDR, SPI_OUT_CHAN0_DDR); set_input(SPI_OUT_DDR, SPI_OUT_CHAN1_DDR); set_input(SPI_OUT_DDR, SPI_OUT_SS_DDR); set_output(SPI_OUT_DDR, SPI_OUT_OK_DDR); output_low(SPI_OUT_PORT, SPI_OUT_OK); // pull-ups on inputs (hi-z doesn't work with 3 slaves) input_pullup(SPI_OUT_PORT, SPI_OUT_CHAN0); input_pullup(SPI_OUT_PORT, SPI_OUT_CHAN1); input_pullup(SPI_OUT_PORT, SPI_OUT_SS); // DI and USCK are inputs. DO is an output, but has to be set as Hi-Z // input to prevent muliple slaves driving one line. set_input(SPI_DDR, SPI_DI_DDR); set_input(SPI_DDR, SPI_USCK_DDR); set_input(SPI_DDR, SPI_DO_DDR); input_pullup(SPI_PORT, SPI_DI); input_pullup(SPI_PORT, SPI_USCK); input_hiz(SPI_PORT, SPI_DO); // enable external interrupt PCINT3 on PB3 (SPI_OUT_SS) PCMSK |= _BV(PCINT3); GIMSK |= _BV(PCIE); // three-wire mode (SPI), external clock (SPI mode 0) USICR = _BV(USIWM0) | _BV(USICS1) /* | _BV(USICS0) */; }
static const char * get_input(struct runinfo *rip) { size_t nread = 0; char *inputp; if (rip->this_one_is_done) { if (rip->more_sources) set_input(rip); else rip->source = NULL; } if (!rip->source) return NULL; nread = fread(rip->input_buf, 1, BUFLEN, rip->source); if (ferror(rip->source)) { fprintf(stderr,"read error\n"); exit(-1); } rip->input_buf[nread] = '\0'; inputp = rip->input_buf; if (!strncmp(inputp,"<?xml",5)) { inputp += 5; while (inputp[0] != '?' && inputp[1] != '>') ++inputp; inputp += 2; while ('\n' == inputp[0] || '\r' == inputp[0]) ++inputp; } if (!strncmp(inputp,"<!DOCTYPE", 9)) { inputp += 9; while ('>' != inputp[0]) ++inputp; ++inputp; while ('\n' == inputp[0] || '\r' == inputp[0]) ++inputp; } nread -= inputp - rip->input_buf; rip->input_len = nread; if ((rip->this_one_is_done = feof(rip->source))) fclose(rip->source); return inputp; }
void set_log(void *bp) { button b = bp; (void)b; main_console->tb_out->data = log_get(); textbox_clear_text(main_console->tb_in); set_input(NULL, 0); main_console->tb_in->active = 0; //main_console->in_bar->active = 0; main_console->tb_out->lines = 18; textbox_find_lines(main_console->tb_out); }
void set_chat(void *bp) { button b = bp; (void)b; main_console->tb_out->data = chat_data; textbox_clear_text(main_console->tb_in); set_input(main_console->tb_in->data, 1000); main_console->tb_in->active = 1; //main_console->in_bar->active = 1; main_console->tb_out->lines = 16; textbox_find_lines(main_console->tb_out); }