/*! * \param[in] sc Selection collection (used for position evaluation). * \param[in] method Method to use. * \param[in] nargs Number of arguments for keyword matching. * \param[in] args Pointer to the first argument. * \param[in] rpost Reference position type to use (NULL = default). * \returns The created selection element. * * This function handles the creation of a \c t_selelem object for * selection methods that do not take parameters. */ t_selelem * _gmx_sel_init_keyword(gmx_ana_selcollection_t *sc, gmx_ana_selmethod_t *method, int nargs, t_selexpr_value *args, const char *rpost) { t_selelem *root, *child; t_selexpr_param *params, *param; int rc; if (method->nparams > 0) { gmx_bug("internal error"); return NULL; } root = _gmx_selelem_create(SEL_EXPRESSION); child = root; set_method(sc, child, method); /* Initialize the evaluation of keyword matching if values are provided */ if (nargs > 0) { gmx_ana_selmethod_t *kwmethod; switch (method->type) { case INT_VALUE: kwmethod = &sm_keyword_int; break; case STR_VALUE: kwmethod = &sm_keyword_str; break; default: _gmx_selparser_error("unknown type for keyword selection"); goto on_error; } root = _gmx_selelem_create(SEL_EXPRESSION); set_method(sc, root, kwmethod); params = param = _gmx_selexpr_create_param(NULL); param->nval = 1; param->value = _gmx_selexpr_create_value_expr(child); param = _gmx_selexpr_create_param(NULL); param->nval = nargs; param->value = args; params->next = param; if (!_gmx_sel_parse_params(params, root->u.expr.method->nparams, root->u.expr.method->param, root)) { _gmx_selparser_error("error in keyword selection initialization"); goto on_error; } } rc = set_refpos_type(sc->pcc, child, rpost); if (rc != 0) { goto on_error; } return root; /* On error, free all memory and return NULL. */ on_error: _gmx_selelem_free(root); return NULL; }
// size is the new size of the instruction at bci. Hence, if size is less than the current // instruction sice, we will shrink the code. methodHandle Relocator::insert_space_at(int bci, int size, u_char inst_buffer[], TRAPS) { _changes = new GrowableArray<ChangeItem*> (10); _changes->push(new ChangeWiden(bci, size, inst_buffer)); if (TraceRelocator) { tty->print_cr("Space at: %d Size: %d", bci, size); _method->print(); _method->print_codes(); tty->print_cr("-------------------------------------------------"); } if (!handle_code_changes()) return methodHandle(); // Construct the new method methodHandle new_method = Method::clone_with_new_data(method(), code_array(), code_length(), compressed_line_number_table(), compressed_line_number_table_size(), CHECK_(methodHandle())); // Deallocate the old Method* from metadata ClassLoaderData* loader_data = method()->method_holder()->class_loader_data(); loader_data->add_to_deallocate_list(method()()); set_method(new_method); if (TraceRelocator) { tty->print_cr("-------------------------------------------------"); tty->print_cr("new method"); _method->print_codes(); } return new_method; }
// size is the new size of the instruction at bci. Hence, if size is less than the current // instruction sice, we will shrink the code. methodHandle Relocator::insert_space_at(int bci, int size, u_char inst_buffer[], TRAPS) { _changes = new GrowableArray<ChangeItem*> (10); _changes->push(new ChangeWiden(bci, size, inst_buffer)); if (TraceRelocator) { tty->print_cr("Space at: %d Size: %d", bci, size); _method->print(); _method->print_codes(); tty->print_cr("-------------------------------------------------"); } if (!handle_code_changes()) return methodHandle(); // Construct the new method methodHandle new_method = methodOopDesc::clone_with_new_data(method(), code_array(), code_length(), compressed_line_number_table(), compressed_line_number_table_size(), CHECK_(methodHandle())); set_method(new_method); if (TraceRelocator) { tty->print_cr("-------------------------------------------------"); tty->print_cr("new method"); _method->print_codes(); } return new_method; }
/*! * \param[in] sc Selection collection. * \param[in] left Selection element for the left hand side. * \param[in] right Selection element for the right hand side. * \param[in] cmpop String representation of the comparison operator. * \returns The created selection element. * * This function handles the creation of a \c t_selelem object for * comparison expressions. */ t_selelem * _gmx_sel_init_comparison(gmx_ana_selcollection_t *sc, t_selelem *left, t_selelem *right, char *cmpop) { t_selelem *sel; t_selexpr_param *params, *param; int rc; sel = _gmx_selelem_create(SEL_EXPRESSION); set_method(sc, sel, &sm_compare); /* Create the parameter for the left expression */ params = param = _gmx_selexpr_create_param(left->v.type == INT_VALUE ? "int1" : "real1"); param->nval = 1; param->value = _gmx_selexpr_create_value_expr(left); /* Create the parameter for the right expression */ param = _gmx_selexpr_create_param(right->v.type == INT_VALUE ? "int2" : "real2"); param->nval = 1; param->value = _gmx_selexpr_create_value_expr(right); params->next = param; /* Create the parameter for the operator */ param = _gmx_selexpr_create_param("op"); param->nval = 1; param->value = _gmx_selexpr_create_value(STR_VALUE); param->value->u.s = cmpop; params->next->next = param; if (!_gmx_sel_parse_params(params, sel->u.expr.method->nparams, sel->u.expr.method->param, sel)) { _gmx_selparser_error("error in comparison initialization"); _gmx_selelem_free(sel); return NULL; } return sel; }
/*! * \param[in] sc Selection collection (used for position evaluation). * \param[in] method Method to use for initialization. * \param[in] params Pointer to the first parameter. * \param[in] rpost Reference position type to use (NULL = default). * \returns The created selection element. * * This function handles the creation of a \c t_selelem object for * selection methods that take parameters. */ t_selelem * _gmx_sel_init_method(gmx_ana_selcollection_t *sc, gmx_ana_selmethod_t *method, t_selexpr_param *params, const char *rpost) { t_selelem *root; int rc; root = _gmx_selelem_create(SEL_EXPRESSION); set_method(sc, root, method); /* Process the parameters */ if (!_gmx_sel_parse_params(params, root->u.expr.method->nparams, root->u.expr.method->param, root)) { _gmx_selelem_free(root); return NULL; } rc = set_refpos_type(sc->pcc, root, rpost); if (rc != 0) { _gmx_selelem_free(root); return NULL; } return root; }
void create_runtime_exception_block( DexString* except_str, std::vector<IRInstruction*>& block) { // new-instance v0, Ljava/lang/RuntimeException; // type@3852 // const-string v1, "Exception String e.g. Too many args" // string@7a6d // invoke-direct {v0, v1}, Ljava/lang/RuntimeException;.<init>:(Ljava/lang/String;)V // throw v0 auto new_inst = (new IRInstruction(OPCODE_NEW_INSTANCE)) ->set_type(DexType::make_type("Ljava/lang/RuntimeException;")); new_inst->set_dest(0); IRInstruction* const_inst = (new IRInstruction(OPCODE_CONST_STRING))->set_string(except_str); const_inst->set_dest(1); auto ret = DexType::make_type("V"); auto arg = DexType::make_type("Ljava/lang/String;"); auto args = DexTypeList::make_type_list({arg}); auto proto = DexProto::make_proto(ret, args); auto meth = DexMethod::make_method( DexType::make_type("Ljava/lang/RuntimeException;"), DexString::make_string("<init>"), proto); auto invk = new IRInstruction(OPCODE_INVOKE_DIRECT); invk->set_method(meth); invk->set_arg_word_count(2); invk->set_src(0, 0); invk->set_src(1, 1); IRInstruction* throwinst = new IRInstruction(OPCODE_THROW); block.emplace_back(new_inst); block.emplace_back(const_inst); block.emplace_back(invk); block.emplace_back(throwinst); }
void InterpretedIC_Iterator::advance() { assert(!at_end(), "iterated over the end"); _index++; if (! at_end()) { if (_pic != NULL) { // polymorphic inline cache int index = _index + 1; // array is 1-origin set_klass (_pic->obj_at(2 * index)); set_method(_pic->obj_at(2 * index - 1)); } else { // predicted send with non_empty inline cache assert(_index < 2, "illegal index"); set_klass(_ic->second_word()); set_method(_ic->first_word()); } } }
void change_visibility(DexMethod* method) { auto code = method->get_code(); always_assert(code != nullptr); editable_cfg_adapter::iterate(code, [](MethodItemEntry& mie) { auto insn = mie.insn; if (insn->has_field()) { auto cls = type_class(insn->get_field()->get_class()); if (cls != nullptr && !cls->is_external()) { set_public(cls); } auto field = resolve_field(insn->get_field(), is_sfield_op(insn->opcode()) ? FieldSearch::Static : FieldSearch::Instance); if (field != nullptr && field->is_concrete()) { set_public(field); set_public(type_class(field->get_class())); // FIXME no point in rewriting opcodes in the method insn->set_field(field); } } else if (insn->has_method()) { auto cls = type_class(insn->get_method()->get_class()); if (cls != nullptr && !cls->is_external()) { set_public(cls); } auto current_method = resolve_method( insn->get_method(), opcode_to_search(insn)); if (current_method != nullptr && current_method->is_concrete()) { set_public(current_method); set_public(type_class(current_method->get_class())); // FIXME no point in rewriting opcodes in the method insn->set_method(current_method); } } else if (insn->has_type()) { auto type = insn->get_type(); auto cls = type_class(type); if (cls != nullptr && !cls->is_external()) { set_public(cls); } } return editable_cfg_adapter::LOOP_CONTINUE; }); std::vector<DexType*> types; if (code->editable_cfg_built()) { code->cfg().gather_catch_types(types); } else { code->gather_catch_types(types); } for (auto type : types) { auto cls = type_class(type); if (cls != nullptr && !cls->is_external()) { set_public(cls); } } }
int jester::parse_options(int argc, char *argv[]) { static const struct option longopts[] = {{"method", required_argument, NULL, 'm'}, {"uri", required_argument, NULL, 'u'}, {"data", required_argument, NULL, 'd'}, {"interactive", no_argument, NULL, 'i'}, {"content", required_argument, NULL, 'c'}, {"header", required_argument, NULL, 'h'}, {NULL, 0, NULL, 0}}; int opt; std::shared_ptr<jest::arg_pair> pair; while ((opt = getopt_long(argc, argv, "u:m:d:ih:", longopts, NULL)) != -1) { switch (opt) { case 'u': set_uri(optarg); break; case 'm': if (!set_method(optarg)) { printf("Unknown HTTP method %s\n", optarg); return EXIT_FAILURE; } break; case 'd': pair = jest::split_arg(optarg, "="); if (!pair) { printf("Data should be in key=value format."); return EXIT_FAILURE; } append_data(*pair); break; case 'c': set_content(optarg); break; case 'i': set_interactive(true); break; case 'h': pair = jest::split_arg(optarg, ":"); if (!pair) { printf("header should be in key:value format."); return EXIT_FAILURE; } append_header(*pair); break; default: syntax(argv[0]); return EXIT_FAILURE; } } return EXIT_SUCCESS; }
void MethodBlock::invoke(IROpcode opcode, DexMethodRef* meth, const std::vector<Location>& args) { always_assert(is_invoke(opcode)); auto invk = new IRInstruction(opcode); uint16_t arg_count = static_cast<uint16_t>(args.size()); invk->set_method(meth)->set_arg_word_count(arg_count); for (uint16_t i = 0; i < arg_count; i++) { auto arg = args.at(i); invk->set_src(i, arg.get_reg()); } push_instruction(invk); }
Relocator::Relocator(methodHandle m, RelocatorListener* listener) { set_method(m); set_code_length(method()->code_size()); set_code_array(NULL); // Allocate code array and copy bytecodes if (!expand_code_array(0)) { // Should have at least MAX_METHOD_LENGTH available or the verifier // would have failed. ShouldNotReachHere(); } set_compressed_line_number_table(NULL); set_compressed_line_number_table_size(0); _listener = listener; }
/*! * \param[in] sc Selection collection. * \param[in] method Modifier to use for initialization. * \param[in] params Pointer to the first parameter. * \param[in] sel Selection element that the modifier should act on. * \returns The created selection element. * * This function handles the creation of a \c t_selelem object for * selection modifiers. */ t_selelem * _gmx_sel_init_modifier(gmx_ana_selcollection_t *sc, gmx_ana_selmethod_t *method, t_selexpr_param *params, t_selelem *sel) { t_selelem *root; t_selelem *mod; t_selexpr_param *vparam; int i; mod = _gmx_selelem_create(SEL_MODIFIER); set_method(sc, mod, method); if (method->type == NO_VALUE) { t_selelem *child; child = sel; while (child->next) { child = child->next; } child->next = mod; root = sel; } else { vparam = _gmx_selexpr_create_param(NULL); vparam->nval = 1; vparam->value = _gmx_selexpr_create_value_expr(sel); vparam->next = params; params = vparam; root = mod; } /* Process the parameters */ if (!_gmx_sel_parse_params(params, mod->u.expr.method->nparams, mod->u.expr.method->param, mod)) { if (mod->child != sel) { _gmx_selelem_free(sel); } _gmx_selelem_free(mod); return NULL; } return root; }
inline void request::process(std::string::iterator begin, std::string::iterator end) { std::string::iterator cursor_start = begin; std::string::iterator cursor_end = std::find(begin,end,' '); if (cursor_end == end) { throw exception("Invalid request line1",status_code::bad_request); } set_method(std::string(cursor_start,cursor_end)); cursor_start = cursor_end+1; cursor_end = std::find(cursor_start,end,' '); if (cursor_end == end) { throw exception("Invalid request line2",status_code::bad_request); } set_uri(std::string(cursor_start,cursor_end)); set_version(std::string(cursor_end+1,end)); }
/*! * \param[in] sc Selection collection. * \param[in] expr Input selection element for the position calculation. * \param[in] type Reference position type or NULL for default. * \param[in] bSelPos Whether the element evaluates the positions for a * selection. * \returns The created selection element. * * This function handles the creation of a \c t_selelem object for * evaluation of reference positions. */ t_selelem * _gmx_sel_init_position(gmx_ana_selcollection_t *sc, t_selelem *expr, const char *type, bool bSelPos) { t_selelem *root; t_selexpr_param *params; int flags; root = _gmx_selelem_create(SEL_EXPRESSION); set_method(sc, root, &sm_keyword_pos); /* Selections use largest static group by default, while * reference positions use the whole residue/molecule. */ flags = bSelPos ? POS_COMPLMAX : POS_COMPLWHOLE; if (bSelPos && sc->bMaskOnly) { flags |= POS_MASKONLY; } /* FIXME: It would be better not to have the string here hardcoded. */ if (type[0] != 'a') { root->u.expr.method->flags |= SMETH_REQTOP; } _gmx_selelem_set_kwpos_type(type, flags, root->u.expr.mdata); /* Create the parameters for the parameter parser. */ params = _gmx_selexpr_create_param(NULL); params->nval = 1; params->value = _gmx_selexpr_create_value_expr(expr); /* Parse the parameters. */ if (!_gmx_sel_parse_params(params, root->u.expr.method->nparams, root->u.expr.method->param, root)) { _gmx_selelem_free(root); return NULL; } return root; }
int http_decoder::on_url(http_parser *parser, const char *at, std::size_t length) { auto p = static_cast<http_decoder*>(parser->data); assert(p); assert(p->message_); auto method = ::http_method_str(static_cast<http_method>(parser->method)); auto request = dynamic_cast<message::http::http_request *>(p->message_); assert(request); request->set_method(std::string(method)); // Note: a request sent proxy contains the first line as below: // => GET http://example.com/some/resource HTTP/1.1 // so, we should convert it into the following before sending it // to server: // => GET /some/resource HTTP/1.1 std::string uri(at, length); if (parser->method != HTTP_CONNECT) { if (uri[0] != '/') { const static std::string http("http://"); auto end = std::string::npos; if(uri.compare(0, http.length(), http) != 0) end = uri.find('/'); else end = uri.find('/', http.length()); if(end == std::string::npos) { uri = '/'; } else { uri.erase(0, end); } } } request->set_uri(uri); return 0; }
hefesto_func_list_ctx *functions); struct hvm_str_method_call_vector { void *(*method)(const char *method, hefesto_common_list_ctx **string_var, hefesto_type_t *otype, hefesto_var_list_ctx **lo_vars, hefesto_var_list_ctx **gl_vars, hefesto_func_list_ctx *functions); }; #define set_method(m) { m } static struct hvm_str_method_call_vector HVM_STR_METHOD_CALL_VECTOR[HEFESTO_STRING_METHODS_NR] = { set_method(hvm_str_at), set_method(hvm_str_len), set_method(hvm_str_match), set_method(hvm_str_replace) }; #undef set_method void *hvm_str_method(const char *method, hefesto_common_list_ctx **string_var, hefesto_type_t *otype, hefesto_var_list_ctx **lo_vars, hefesto_var_list_ctx **gl_vars, hefesto_func_list_ctx *functions) { char call[HEFESTO_MAX_BUFFER_SIZE];
bool message::set_method( const std::string& req, const std::string& ver ) { return set_method( message::method( message_const::to_verb( req ), message_const::to_api( ver ) ) ); }
bool message::set_method( const std::string& req ) { return set_method( req, message_const::to_string( message::method::http_v10 ) ); }
void InterpretedIC_Iterator::init_iteration() { _pic = NULL; _index = 0; // determine initial state switch (_ic->send_type()) { case Bytecodes::interpreted_send: if (_ic->is_empty()) { // anamorphic call site (has never been executed => no type information) _number_of_targets = 0; _info = anamorphic; } else { // monomorphic call site _number_of_targets = 1; _info = monomorphic; set_klass(_ic->second_word()); set_method(_ic->first_word()); } break; case Bytecodes::compiled_send : _number_of_targets = 1; _info = monomorphic; set_klass(_ic->second_word()); assert(_ic->first_word()->is_smi(), "must have jumpTableEntry"); set_method(_ic->first_word()); assert(is_compiled(), "bad type"); break; case Bytecodes::accessor_send : // fall through case Bytecodes::primitive_send : _number_of_targets = 1; _info = monomorphic; set_klass(_ic->second_word()); set_method(_ic->first_word()); assert(is_interpreted(), "bad type"); break; case Bytecodes::megamorphic_send: // no type information stored _number_of_targets = 0; _info = megamorphic; break; case Bytecodes::polymorphic_send: // information on many types _pic = objArrayOop(_ic->second_word()); _number_of_targets = _pic->length() / 2; _info = polymorphic; set_klass(_pic->obj_at(2)); set_method(_pic->obj_at(1)); break; case Bytecodes::predicted_send: if (_ic->is_empty() || _ic->second_word() == smiKlassObj) { _number_of_targets = 1; _info = monomorphic; } else { _number_of_targets = 2; _info = polymorphic; } set_klass(smiKlassObj); set_method(interpreter_normal_lookup(smiKlassObj, selector()).value()); assert(_method != NULL && _method->is_mem(), "this method must be there"); break; default: ShouldNotReachHere(); } assert((number_of_targets() > 1) == (_info == polymorphic), "inconsistency"); }
void ciSpeculativeTrapData::translate_from(const ProfileData* data) { Method* m = data->as_SpeculativeTrapData()->method(); ciMethod* ci_m = CURRENT_ENV->get_method(m); CURRENT_ENV->ensure_metadata_alive(ci_m); set_method(ci_m); }
int main(int argc, char *argv[]) { #else int gstat_main(int argc, char *argv[]) { #endif DATA **data = NULL, *valdata = NULL; /* * initialise some global variables: */ atexit(close_gstat_log_file); init_userio(1); init_global_variables(); argv0 = argv[0]; /* * register command line arguments on command_line: */ command_line = store_argv(argc, argv); parse_gstatrc(); /* * INPUT: command line options; */ parse_options(argc, argv); /* exits on -e options */ /* * start with program heading: */ printlog("%s: %s version %s\n", GSTAT_NAME, GSTAT_OS, VERSION); printlog("%s\n", GSTAT_CR); gstat_start(); /* * INPUT: Parse command files: */ if (optind == argc) { /* there's no command file name left */ if (get_method() != UIF) { /* -i or -m command line option */ /* no arguments */ printlog("Updates, manuals and source code: %s\n", GSTAT_HOME); printlog("%s\n", USAGE); ErrMsg(ER_NOCMD, ""); } else { start_ui(); exit(0); } } else { /* we have a command file to be read */ for ( ; optind < argc; optind++) { command_file_name = argv[optind]; parse_file(command_file_name); if (logfile_name != NULL) set_gstat_log_file(efopen(logfile_name, "w")); /* * get global variables locally: */ data = get_gstat_data(); valdata = get_dataval(); set_seed(gl_seed); /* * check variable settings and next * INPUT: read data values from file: */ read_all_data(data, valdata, get_n_vars()); if (get_method() == NSP) /* Still no answer to this: choose default */ set_method(get_default_method()); set_mode(); check_global_variables(); setup_meschach_error_handler(); if (DEBUG_DUMP) dump_all(); if (get_method() != NSP) printlog("[%s]\n", method_string(get_method())); if (check_only) set_method(NSP); /* * start calculations && OUTPUT routines: */ switch (get_method()) { case UIF: start_ui(); break; case NSP: break; case COV: case SEM: do_variogram(get_n_vars(), get_method()); break; case POLY: setup_poly_method(); /*FALLTHROUGH*/ default: if (gl_xvalid) /* validation/cross validation */ cross_valid(data); else predict_all(data); /* or prediction: */ break; } /* switch get_method() */ remove_all(); /* free all data etc. */ init_global_variables(); /* re-init for next round */ } } if (DEBUG_DUMP) atexit(print_file_record); if (get_method() != UIF) elapsed(); /* * file closing & data freeing time: */ if (plotfile != NULL) efclose(plotfile); exit(0); } /* end of main() */
static void parse_options(int argc, char *argv[]) { int c; /* who am i, some -e option? */ if (argc > 1 && almost_equals(argv[1], "-e$xecute")) exit(exec_action(argc - 2, argv + 2)); /* no, we're plain gstat. Parse the command line: */ opterr = 0; while ((c = getopt(argc, argv, "Ccd:ehil:mo:p:sSvWxV")) != EOF) { switch (c) { case 'd': if (read_int(optarg, &debug_level) || debug_level < 0) { debug_level = 1; message(DEBUG_OPTIONS); ErrMsg(ER_ARGOPT, "d"); } break; case 'e': ErrMsg(ER_ARGOPT, "option -e only allowed as first option"); case 'i': case 'm': set_method(UIF); break; case 'l': set_gstat_log_file(efopen(logfile_name = optarg, "w")); break; case 'o': o_filename = optarg; break; case 'p': gl_plotfile = optarg; break; case 'S': gl_secure = 1; break; case 's': debug_level = 0; break; case 'c': check_only = 1; break; case 'x': gl_xvalid = 1; break; case 'C': printlog("%s\n", COPYRIGHT); break; case 'W': printlog("%s\n", NOWARRANTY); break; case 'V': case 'v': printlog("compiled on: %s\n", __DATE__); printlog("with libraries: "); #ifdef HAVE_LIBCSF printlog("csf "); #endif #ifdef HAVE_LIBCURSES printlog("curses "); #endif #ifdef HAVE_LIBGD printlog("gd "); # ifdef HAVE_GDIMAGEGIF printlog("(gif) "); # else printlog("(png) "); # endif #endif #ifdef HAVE_LIBGIS printlog("grass "); #endif #ifdef HAVE_LIBGSL printlog("gsl "); #endif #ifdef HAVE_LIBNCURSES printlog("ncurses "); #endif #ifdef HAVE_LIBNETCDF printlog("netcdf "); #endif #ifdef LIBGSTAT printlog("qt "); #endif #ifdef HAVE_LIBREADLINE printlog("readline "); #endif printlog("\n"); printlog("last modified on: %s\n", LASTMOD); printlog("gstat home page: %s\n", GSTAT_HOME); printlog("questions, bugs etc. mailto:%s\n\n", GSTAT_INFO); break; case 'h': printlog("%s\n\n%s\n", USAGE, HELP); break; case '?': default: ErrClo(optopt); } } return; }
static int do_option(int optc, const char *arg) { int i = 0; switch (optc) { #if 0 // FIXME: to_stdout doesn't work because of console code mess //case 'c': case 517: opt->to_stdout = true; break; #endif case 'd': set_cmd(CMD_DECOMPRESS); break; case 'D': opt->debug.debug_level++; break; case 'f': opt->force++; break; case 909: set_cmd(CMD_FILEINFO); break; case 'h': case 'H': case '?': set_cmd(CMD_HELP); break; case 'h'+256: #if 1 if (!acc_isatty(STDOUT_FILENO)) { /* according to GNU standards */ set_term(stdout); opt->console = CON_FILE; } #endif show_help(1); e_exit(EXIT_OK); break; case 'i': opt->info_mode++; break; case 'l': set_cmd(CMD_LIST); break; case 'L': set_cmd(CMD_LICENSE); break; case 'o': set_output_name(mfx_optarg,1); break; case 'q': opt->verbose = (opt->verbose > 1 ? 1 : opt->verbose - 1); break; case 't': set_cmd(CMD_TEST); break; case 'v': opt->verbose = (opt->verbose < 3 ? 3 : opt->verbose + 1); break; case 'V': set_cmd(CMD_VERSION); break; case 'V'+256: /* according to GNU standards */ set_term(stdout); opt->console = CON_FILE; show_version(0); e_exit(EXIT_OK); break; // method case 702: opt->method_nrv2b_seen = true; if (!set_method(M_NRV2B_LE32, -1)) e_method(M_NRV2B_LE32, opt->level); break; case 704: opt->method_nrv2d_seen = true; if (!set_method(M_NRV2D_LE32, -1)) e_method(M_NRV2D_LE32, opt->level); break; case 705: opt->method_nrv2e_seen = true; if (!set_method(M_NRV2E_LE32, -1)) e_method(M_NRV2E_LE32, opt->level); break; case 721: opt->method_lzma_seen = true; opt->all_methods_use_lzma = true; if (!set_method(M_LZMA, -1)) e_method(M_LZMA, opt->level); break; case 722: opt->method_lzma_seen = false; opt->all_methods_use_lzma = false; if (M_IS_LZMA(opt->method)) opt->method = -1; break; // compression level case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (!set_method(-1, optc - '0')) e_method(opt->method, optc); break; case 902: // --ultra-brute opt->ultra_brute = true; /* fallthrough */ case 901: // --brute opt->all_methods = true; opt->all_methods_use_lzma = true; opt->method = -1; opt->all_filters = true; opt->filter = -1; opt->crp.crp_ucl.m_size = 999999; /* fallthrough */ case 900: // --best if (!set_method(-1, 10)) e_method(opt->method, 10); break; // debug case 542: if (!mfx_optarg || strlen(mfx_optarg) != 4) e_optarg(arg); memcpy(opt->debug.fake_stub_version, mfx_optarg, 4); break; case 543: if (!mfx_optarg || strlen(mfx_optarg) != 4) e_optarg(arg); memcpy(opt->debug.fake_stub_year, mfx_optarg, 4); break; case 544: if (!mfx_optarg || !mfx_optarg[0]) e_optarg(arg); opt->debug.dump_stub_loader = mfx_optarg; break; case 545: opt->debug.disable_random_id = true; break; // mp (meta) case 501: getoptvar(&opt->mp_compress_task, 1, 999999, arg); break; case 502: opt->mp_query_format = true; break; case 503: opt->mp_query_num_tasks = true; break; // misc case 512: opt->console = CON_FILE; break; case 513: opt->console = CON_ANSI_MONO; break; case 514: opt->console = CON_ANSI_COLOR; break; case 516: opt->no_progress = true; break; case 519: opt->no_env = true; break; case 526: opt->preserve_mode = false; break; case 527: opt->preserve_ownership = false; break; case 528: opt->preserve_timestamp = false; break; // compression settings case 520: // --small if (opt->small < 0) opt->small = 0; opt->small++; break; case 521: // --filter= getoptvar(&opt->filter, 0, 255, arg); opt->all_filters = false; break; case 522: // --no-filter opt->filter = 0; opt->all_filters = false; opt->no_filter = true; break; case 523: // --all-filters opt->all_filters = true; opt->filter = -1; break; case 524: // --all-methods opt->all_methods = true; opt->all_methods_use_lzma = true; opt->method = -1; break; case 525: // --exact opt->exact = true; break; // compression runtime parameters case 801: getoptvar(&opt->crp.crp_ucl.c_flags, 0, 3, arg); break; case 802: getoptvar(&opt->crp.crp_ucl.s_level, 0, 2, arg); break; case 803: getoptvar(&opt->crp.crp_ucl.h_level, 0, 1, arg); break; case 804: getoptvar(&opt->crp.crp_ucl.p_level, 0, 7, arg); break; case 805: getoptvar(&opt->crp.crp_ucl.max_offset, 256u, ~0u, arg); break; case 806: getoptvar(&opt->crp.crp_ucl.max_match, 16u, ~0u, arg); break; case 807: getoptvar(&opt->crp.crp_ucl.m_size, 10000u, 999999u, arg); break; case 811: getoptvar(&opt->crp.crp_lzma.pos_bits, arg); break; case 812: getoptvar(&opt->crp.crp_lzma.lit_pos_bits, arg); break; case 813: getoptvar(&opt->crp.crp_lzma.lit_context_bits, arg); break; case 814: getoptvar(&opt->crp.crp_lzma.dict_size, arg); break; case 816: getoptvar(&opt->crp.crp_lzma.num_fast_bytes, arg); break; case 821: getoptvar(&opt->crp.crp_zlib.mem_level, arg); break; case 822: getoptvar(&opt->crp.crp_zlib.window_bits, arg); break; case 823: getoptvar(&opt->crp.crp_zlib.strategy, arg); break; // backup case 'k': opt->backup = 1; break; case 541: if (opt->backup != 1) // do not overide '--backup' opt->backup = 0; break; // overlay case 551: if (mfx_optarg && strcmp(mfx_optarg,"skip") == 0) opt->overlay = opt->SKIP_OVERLAY; else if (mfx_optarg && strcmp(mfx_optarg,"copy") == 0) opt->overlay = opt->COPY_OVERLAY; else if (mfx_optarg && strcmp(mfx_optarg,"strip") == 0) opt->overlay = opt->STRIP_OVERLAY; else e_optarg(arg); break; case 552: opt->overlay = opt->SKIP_OVERLAY; break; case 553: opt->overlay = opt->COPY_OVERLAY; break; case 554: opt->overlay = opt->STRIP_OVERLAY; break; // CPU case 560: if (mfx_optarg && strcmp(mfx_optarg,"8086") == 0) opt->cpu = opt->CPU_8086; else if (mfx_optarg && strcmp(mfx_optarg,"386") == 0) opt->cpu = opt->CPU_386; else if (mfx_optarg && strcmp(mfx_optarg,"486") == 0) opt->cpu = opt->CPU_486; else e_optarg(arg); break; case 561: opt->cpu = opt->CPU_8086; break; case 563: opt->cpu = opt->CPU_386; break; case 564: opt->cpu = opt->CPU_486; break; // case 600: opt->dos_exe.force_stub = true; break; case 601: opt->dos_exe.no_reloc = true; break; case 610: opt->djgpp2_coff.coff = true; break; case 620: opt->watcom_le.le = true; break; case 630: opt->win32_pe.compress_exports = 1; if (mfx_optarg && mfx_optarg[0]) getoptvar(&opt->win32_pe.compress_exports, 0, 1, arg); //printf("compress_exports: %d\n", opt->win32_pe.compress_exports); break; case 631: opt->win32_pe.compress_icons = 1; if (mfx_optarg && mfx_optarg[0]) getoptvar(&opt->win32_pe.compress_icons, 0, 3, arg); //printf("compress_icons: %d\n", opt->win32_pe.compress_icons); break; case 632: opt->win32_pe.compress_resources = 1; if (mfx_optarg && mfx_optarg[0]) getoptvar(&opt->win32_pe.compress_resources, 0, 1, arg); //printf("compress_resources: %d\n", opt->win32_pe.compress_resources); break; case 633: // opt->win32_pe.strip_loadconf - OBSOLETE - IGNORED break; case 634: opt->win32_pe.strip_relocs = 1; if (mfx_optarg && mfx_optarg[0]) getoptvar(&opt->win32_pe.strip_relocs, 0, 1, arg); //printf("strip_relocs: %d\n", opt->win32_pe.strip_relocs); break; case 635: if (!mfx_optarg || !mfx_optarg[0]) e_optarg(arg); opt->win32_pe.keep_resource = mfx_optarg; break; case 650: opt->atari_tos.split_segments = true; break; case 660: getoptvar(&opt->o_unix.blocksize, 8192u, ~0u, arg); break; case 661: opt->o_unix.force_execve = true; break; case 662: opt->o_unix.script_name = "/usr/local/lib/upx/upxX"; if (mfx_optarg && mfx_optarg[0]) set_script_name(mfx_optarg, 1); break; case 663: opt->o_unix.is_ptinterp = true; break; case 664: opt->o_unix.use_ptinterp = true; break; case 665: opt->o_unix.make_ptinterp = true; break; case 666: // Linux opt->o_unix.osabi0 = Elf32_Ehdr::ELFOSABI_LINUX; break; case 667: // FreeBSD opt->o_unix.osabi0 = Elf32_Ehdr::ELFOSABI_FREEBSD; break; case 668: // NetBSD opt->o_unix.osabi0 = Elf32_Ehdr::ELFOSABI_NETBSD; break; case 669: // OpenBSD opt->o_unix.osabi0 = Elf32_Ehdr::ELFOSABI_OPENBSD; break; case 670: opt->ps1_exe.boot_only = true; break; case 671: opt->ps1_exe.no_align = true; opt->ps1_exe.boot_only = false; break; case 672: opt->ps1_exe.do_8bit = true; break; case 673: opt->ps1_exe.do_8mib = false; break; case 674: opt->o_unix.unmap_all_pages = true; // val ? break; case '\0': return -1; case ':': return -2; default: fprintf(stderr,"%s: internal error in getopt (%d)\n", argv0, optc); return -3; } UNUSED(i); return 0; }
static int ssh2_drive_session(eventer_t e, int mask, void *closure, struct timeval *now) { int i; const char *fingerprint; ssh2_check_info_t *ci = closure; struct timeval diff; int timeout_ms = 10; /* 10ms, gets set below */ if(ci->state == WANT_CLOSE) { noit_check_t *check = ci->check; ssh2_log_results(ci->self, ci->check); ssh2_cleanup(ci->self, ci->check); eventer_remove_fd(e->fd); e->opset->close(e->fd, &mask, e); check->flags &= ~NP_RUNNING; return 0; } switch(mask) { case EVENTER_ASYNCH_WORK: if(eventer_set_fd_blocking(e->fd)) { ci->timed_out = 0; ci->error = strdup("socket error"); return 0; } ci->session = libssh2_session_init(); #define set_method(a,b) do { \ int rv; \ if(ci->methods.a && \ (rv = libssh2_session_method_pref(ci->session, b, ci->methods.a)) != 0) { \ ci->timed_out = 0; \ ci->error = strdup((rv == LIBSSH2_ERROR_METHOD_NOT_SUPPORTED) ? \ #a " method not supported" : "error setting " #a); \ return 0; \ } \ } while(0) set_method(kex, LIBSSH2_METHOD_KEX); set_method(hostkey, LIBSSH2_METHOD_HOSTKEY); set_method(crypt_cs, LIBSSH2_METHOD_CRYPT_CS); set_method(crypt_sc, LIBSSH2_METHOD_CRYPT_SC); set_method(mac_cs, LIBSSH2_METHOD_MAC_CS); set_method(mac_sc, LIBSSH2_METHOD_MAC_SC); set_method(comp_cs, LIBSSH2_METHOD_COMP_CS); set_method(comp_sc, LIBSSH2_METHOD_COMP_SC); if(compare_timeval(*now, e->whence) < 0) { sub_timeval(e->whence, *now, &diff); timeout_ms = diff.tv_sec * 1000 + diff.tv_usec / 1000; } #if LIBSSH2_VERSION_NUM >= 0x010209 libssh2_session_set_timeout(ci->session, timeout_ms); #endif if (libssh2_session_startup(ci->session, e->fd)) { ci->timed_out = 0; ci->error = strdup("ssh session startup failed"); return 0; } fingerprint = libssh2_hostkey_hash(ci->session, LIBSSH2_HOSTKEY_HASH_MD5); for(i=0;i<16;i++) { snprintf(ci->fingerprint + (i*2), 3, "%02x", (unsigned char)fingerprint[i]); } ci->fingerprint[32] = '\0'; ci->timed_out = 0; return 0; break; case EVENTER_ASYNCH_CLEANUP: if(ci->session) { libssh2_session_disconnect(ci->session, "Bye!"); libssh2_session_free(ci->session); ci->session = NULL; } ci->state = WANT_CLOSE; break; default: abort(); } return 0; }
void LogitEMC::set_prior(Ptr<MvnBase> pri){ pri_ = pri; NEW(LogitSampler, sam)(this, pri); set_method(sam); }
void set_method(Oop* value) { set_method( value->obj() ); }