int main( int argc, char ** argv ) { Eigen::Vector3d shift_hist; BWCNC::PartContext k; if( handle_params( argc, argv ) ) { BWCNC::HexGrid grid( parms.cols, parms.rows, parms.sidelen, parms.nested, parms.nested_spacing, ! parms.suppress_grid ); grid.fill_partctx_with_grid( k ); //k.remake_boundingbox(); shift2center( k, &shift_hist ); k.position_dependent_transform( skew_tform, shift_tform ); //k.remake_boundingbox(); k.scale( parms.scale ); k.position_dependent_transform( rotation_tform, nullptr ); //k.remake_boundingbox(); undo_shift2( k, shift_hist ); BWCNC::SVG renderer; renderer.set_moveto_color( parms.moveto_clr ); renderer.set_lineto_color( parms.lineto_clr ); renderer.render_all( k ); } return 0; }
TEE_Result TA_EXPORT TA_InvokeCommandEntryPoint(void *sessionContext, uint32_t commandID, uint32_t paramTypes, TEE_Param params[4]) { TEE_Result tee_rv = TEE_SUCCESS; /* Check session context */ if (TEE_MemCompare(sessionContext, out_vector, SIZE_OF_VEC(out_vector))) { OT_LOG(LOG_ERR, "Not a correct session context"); return TEE_ERROR_GENERIC; } if (!(commandID == INVOKE_CMD_ID_1 || commandID == INVOKE_CMD_ID_2)) { OT_LOG(LOG_ERR, "Not a valid command ID"); return TEE_ERROR_BAD_PARAMETERS; } tee_rv = handle_params(paramTypes, params); if (tee_rv != TEE_SUCCESS) return tee_rv; if (storage_test(2)) return TEE_ERROR_GENERIC; if (crypto_test(2)) return TEE_ERROR_GENERIC; return TEE_SUCCESS; }
TEE_Result TA_EXPORT TA_OpenSessionEntryPoint(uint32_t paramTypes, TEE_Param params[4], void **sessionContext) { TEE_Result tee_rv = TEE_SUCCESS; OT_LOG(LOG_INFO, "Calling the Open session entry point"); tee_rv = handle_params(paramTypes, params); if (tee_rv != TEE_SUCCESS) return tee_rv; if (storage_test(2)) return TEE_ERROR_GENERIC; if (crypto_test(2)) return TEE_ERROR_GENERIC; if (*sessionContext != NULL) { OT_LOG(LOG_ERR, "Session context should be NULL"); return TEE_ERROR_BAD_PARAMETERS; } *sessionContext = TEE_Malloc(SIZE_OF_VEC(out_vector), 0); if (*sessionContext == NULL) { OT_LOG(LOG_ERR, "Can not malloc space for session context"); return TEE_ERROR_OUT_OF_MEMORY; } TEE_MemMove(*sessionContext, out_vector, SIZE_OF_VEC(out_vector)); return tee_rv; }
int textsearch(char *params) { handle_params(params); ask_params(); if (!*search_str) return 1; do_conference_wide_scan(); return 1; }
void write_commands(t_info *info, int fd) { t_list *crawl; t_list *temp; t_command com; crawl = info->commands; while (crawl != NULL) { com = *((t_command *)crawl->data); write(fd, &com.opcode, sizeof(com.opcode)); if (com.encoding_byte != '\0') write(fd, &com.encoding_byte, sizeof(com.encoding_byte)); handle_params(info, com, fd); temp = crawl; crawl = crawl->next; } while (crawl != NULL) { free_commands((t_command *)crawl->data); free(temp); } }
/* * Where everything happens. */ void physics_worker::main_loop () { physics_update u {}; const static int updates_per_tick = 8000; int i, fcount; std::minstd_rand rnd ((utils::ns_since_epoch ())); while (this->_running) { std::this_thread::sleep_for (std::chrono::milliseconds (50)); ++ this->ticks; if (paused) continue; fcount = 0; // failure counter for (i = 0; i < updates_per_tick; ++i) { if (!this->_running || paused || this->man.updates.empty ()) break; if (!this->man.updates.try_pop (u)) { ++ fcount; if (fcount % 15 == 0) std::this_thread::sleep_for (std::chrono::milliseconds (2)); if (fcount == 60) break; continue; } if (u.nt > std::chrono::steady_clock::now ()) { this->man.updates.push (u); continue; } // parameters if (!handle_params (u, this->man, this->rnd)) continue; if (u.type == PU_BLOCK) { auto blk = u.data.blk; this->man.remove_block (u.w, blk.x, blk.y, blk.z); // does this block have a custom callback attached? if (blk.cb) { blk.cb (*u.w, blk.x, blk.y, blk.z, blk.extra, rnd); } else { // nope, use the one associated with its ID physics_block *pb = (u.w)->get_physics_at (blk.x, blk.y, blk.z); if (pb) pb->tick (*u.w, blk.x, blk.y, blk.z, blk.extra, nullptr, rnd); } } else if (u.type == PU_ENTITY) { auto ent = u.data.ent; if (ent.e->get_type () == ET_PLAYER) { player *pl = dynamic_cast<player *> (ent.e); if (pl->get_world () != u.w) continue; } if (!ent.e->tick (*u.w) && ent.persistent) { // requeue physics_update nu = u; nu.nt = std::chrono::steady_clock::now () + std::chrono::milliseconds (50 * nu.tick); man.updates.push (nu); } } } } }
int cmd_rxtx(struct cli_state *s, int argc, char **argv) { int ret = CMD_RET_OK; int fpga_loaded; enum rxtx_cmd cmd; struct common_cfg *common; bool is_tx; int (*start_init)(struct cli_state *s); int (*stop_cleanup)(struct cli_state *s); if (!strcasecmp("tx", argv[0])) { is_tx = true; common = &s->rxtx_data->tx.common; start_init = tx_start_init; stop_cleanup = tx_stop_cleanup; } else if (!strcasecmp("rx", argv[0])) { is_tx = false; common = &s->rxtx_data->rx.common; start_init = rx_start_init; stop_cleanup = rx_stop_cleanup; } else { /* Bug */ assert(0); return CMD_RET_UNKNOWN; } /* Just <rx|tx> is supported shorthand for <rx|tx> config */ if (argc == 1) { cmd = RXTX_CMD_CFG; } else { cmd = get_cmd(argv[1]); } switch (cmd) { case RXTX_CMD_START: if (!cli_device_is_opened(s)) { ret = CMD_RET_NODEV; } else if (get_state(common) == RXTX_STATE_RUNNING) { ret = CMD_RET_STATE; } else { fpga_loaded = bladerf_is_fpga_configured(s->dev); if (fpga_loaded < 0) { s->last_lib_error = fpga_loaded; ret = CMD_RET_LIBBLADERF; } else if (!fpga_loaded) { cli_err(s, argv[0], "FPGA is not configured"); ret = CMD_RET_INVPARAM; } else { ret = validate_config(s, argv[0], s->rxtx_data, is_tx); if (!ret) { ret = open_samples_file(common, NULL, is_tx ? "r" : "w"); if (!ret) { ret = start_init(s); } } } } break; case RXTX_CMD_STOP: if (!cli_device_is_opened(s)) { ret = CMD_RET_NODEV; } else if (get_state(common) != RXTX_STATE_RUNNING) { ret = CMD_RET_STATE; } else { ret = stop_cleanup(s); } break; case RXTX_CMD_CFG: if (argc > 2) { if (get_state(common) != RXTX_STATE_RUNNING) { ret = handle_params(s, argc, argv, is_tx); } else { ret = CMD_RET_STATE; } } else { print_config(s->rxtx_data, is_tx); } break; default: cli_err(s, argv[0], "Invalid command (%s)", argv[1]); ret = CMD_RET_INVPARAM; } return ret; }
int main(int argc, char **argv) { int result = 0; int i; userui_ops[0] = &userui_text_ops; userui_ops[1] = FBSPLASH_OPS; userui_ops[2] = USPLASH_OPS; active_ops = &userui_text_ops; handle_params(argc, argv); setup_signal_handlers(); open_console(); open_misc(); if (!test_run) { open_netlink(); get_nofreeze(); get_info(); } lock_memory(); prepare_console(); /* Initialise all that we can, use the first */ // active_ops = NULL; for (i = 0; i < NUM_UIS; i++) { if (userui_ops[i] && userui_ops[i]->load) { result = userui_ops[i]->load(); if (result) { if (test_run) fprintf(stderr, "Failed to initialise %s module.\n", userui_ops[i]->name); else printk("Failed to initialise %s module.\n", userui_ops[i]->name); } else if (!active_ops) active_ops = userui_ops[i]; } } if (active_ops->prepare) active_ops->prepare(); register_keypress_handler(); need_cleanup = 1; running = 1; result = nice(1); if (active_ops->memory_required) reserve_memory(active_ops->memory_required()); else reserve_memory(4*1024*1024); /* say 4MB */ enforce_lifesavers(); if (test_run) { safe_to_exit = 0; do_test_run(); return 0; } if (send_ready()) message_loop(); /* The only point we ever reach here is if message_loop crashed out. * If this is the case, we should spin for a few hours before exiting to * ensure that we don't corrupt stuff on disk (if we're past the atomic * copy). */ sleep(60*60*1); /* 1 hours */ _exit(1); }