void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid) { #ifdef TOOLS_ENABLED _edited = true; #endif if (script_instance) { if (script_instance->set(p_name, p_value)) { if (r_valid) *r_valid = true; return; } } //try built-in setgetter { if (ClassDB::set_property(this, p_name, p_value, r_valid)) { /* if (r_valid) *r_valid=true; */ return; } } if (p_name == CoreStringNames::get_singleton()->_script) { set_script(p_value); if (r_valid) *r_valid = true; return; } else if (p_name == CoreStringNames::get_singleton()->_meta) { //set_meta(p_name,p_value); metadata = p_value; if (r_valid) *r_valid = true; return; #ifdef TOOLS_ENABLED } else if (p_name == CoreStringNames::get_singleton()->_sections_unfolded) { Array arr = p_value; for (int i = 0; i < arr.size(); i++) { editor_section_folding.insert(arr[i]); } if (r_valid) *r_valid = true; return; #endif } else { //something inside the object... :| bool success = _setv(p_name, p_value); if (success) { if (r_valid) *r_valid = true; return; } setvar(p_name, p_value, r_valid); } }
void MainLoop::finish() { if (get_script_instance()) { get_script_instance()->call("_finalize"); set_script(RefPtr()); //clear script } }
bool MultiScript::_set(const StringName& p_name, const Variant& p_value) { _THREAD_SAFE_METHOD_ String s = String(p_name); if (s.begins_with("script_")) { int idx = s[7]; if (idx==0) return false; idx-='a'; ERR_FAIL_COND_V(idx<0,false); Ref<Script> s = p_value; if (idx<scripts.size()) { if (s.is_null()) remove_script(idx); else set_script(idx,s); } else if (idx==scripts.size()) { if (s.is_null()) return false; add_script(s); } else return false; return true; } return false; }
bitmap_source_script(k3d::iplugin_factory& Factory, k3d::idocument& Document) : base(Factory, Document) { set_script(k3d::resource::get_string("/module/scripting/bitmap_source_script.py")); connect_script_changed_signal(k3d::hint::converter< k3d::hint::convert<k3d::hint::any, k3d::hint::none> >(make_update_bitmap_slot())); }
void MainLoop::init() { if (init_script.is_valid()) set_script(init_script.get_ref_ptr()); if (get_script_instance()) get_script_instance()->call("_initialize"); }
void Object::set(const StringName& p_name, const Variant& p_value, bool *r_valid) { #ifdef TOOLS_ENABLED _edited=true; #endif if (script_instance) { if (script_instance->set(p_name,p_value)) { if (r_valid) *r_valid=true; return; } } //try built-in setgetter { if (ObjectTypeDB::set_property(this,p_name,p_value,r_valid)) { //if (r_valid) // *r_valid=true; return; } } if (p_name==CoreStringNames::get_singleton()->_script) { set_script(p_value); if (r_valid) *r_valid=true; return; } else if (p_name==CoreStringNames::get_singleton()->_meta) { //set_meta(p_name,p_value); metadata=p_value; if (r_valid) *r_valid=true; return; } else { //something inside the object... :| bool success = _setv(p_name,p_value); if (success) { if (r_valid) *r_valid=true; return; } setvar(p_name,p_value,r_valid); } }
int BlinkM::ioctl(device::file_t *filp, int cmd, unsigned long arg) { int ret = ENOTTY; switch (cmd) { case BLINKM_PLAY_SCRIPT_NAMED: if (arg == 0) { ret = EINVAL; break; } ret = play_script((const char *)arg); break; case BLINKM_PLAY_SCRIPT: ret = play_script(arg); break; case BLINKM_SET_USER_SCRIPT: { if (arg == 0) { ret = EINVAL; break; } unsigned lines = 0; const uint8_t *script = (const uint8_t *)arg; while ((lines < 50) && (script[1] != 0)) { ret = write_script_line(lines, script[0], script[1], script[2], script[3], script[4]); if (ret != OK) { break; } script += 5; } if (ret == OK) { ret = set_script(lines, 0); } break; } default: break; } return ret; }
void Object::set(const String& p_name, const Variant& p_value) { _setv(p_name,p_value); //if (!_use_builtin_script()) // return; bool success; ObjectTypeDB::set_property(this,p_name,p_value,success); if (success) { return; } if (p_name=="__meta__") { metadata=p_value; } else if (p_name=="script/script") { set_script(p_value); } else if (script_instance) { script_instance->set(p_name,p_value); } }
action_script() { set_script(k3d::resource::get_string("/module/scripting/action_script.py")); }
void MaterialDescription::load_xml(const xmlNodePtr node) { xmlNodePtr it; Uint32 i; SamplerParameterType sampler; if (node == 0) { EL_THROW_EXCEPTION(InvalidParameterException() << errinfo_message(UTF8("parameter is zero")) << errinfo_parameter_name(UTF8("node"))); } if (xmlStrcmp(node->name, BAD_CAST UTF8("material")) != 0) { return; } it = XmlUtil::children(node, true); do { for (i = 0; i < m_textures.size(); ++i) { sampler = static_cast<SamplerParameterType>(i); if (xmlStrcmp(it->name, BAD_CAST SamplerParameterUtil::get_str( sampler).get().c_str()) == 0) { set_texture(XmlUtil::get_string_value( it), sampler); set_sRGB(XmlUtil::get_bool_property(it, String(UTF8("sRGB"))), sampler); set_rectangle( XmlUtil::get_bool_property(it, String(UTF8( "rectangle")), false), sampler); } } if (xmlStrcmp(it->name, BAD_CAST UTF8("name")) == 0) { set_name(XmlUtil::get_string_value(it)); } if (xmlStrcmp(it->name, BAD_CAST UTF8("effect")) == 0) { set_effect(XmlUtil::get_string_value(it)); } if (xmlStrcmp(it->name, BAD_CAST UTF8("script")) == 0) { set_script(XmlUtil::get_string_value(it)); } if (xmlStrcmp(it->name, BAD_CAST UTF8("texture_matrix_0")) == 0) { set_texture_matrix( XmlUtil::get_mat2x3_value(it), 0); } if (xmlStrcmp(it->name, BAD_CAST UTF8("texture_matrix_1")) == 0) { set_texture_matrix( XmlUtil::get_mat2x3_value(it), 1); } if (xmlStrcmp(it->name, BAD_CAST UTF8("color")) == 0) { set_color(XmlUtil::get_vec4_value(it)); } if (xmlStrcmp(it->name, BAD_CAST UTF8("dudv_scale_offset")) == 0) { set_dudv_scale_offset(XmlUtil::get_vec4_value( it)); } if (xmlStrcmp(it->name, BAD_CAST UTF8("cast_shadows")) == 0) { set_cast_shadows(XmlUtil::get_bool_value(it)); } if (xmlStrcmp(it->name, BAD_CAST UTF8("culling")) == 0) { set_culling(XmlUtil::get_bool_value(it)); } } while (XmlUtil::next(it, true)); }
void parse_options(int argc, char **argv) { int c; static struct option long_options[] = { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'v' }, { "iface", required_argument, NULL, 'i' }, { "lifaces", no_argument, NULL, 'I' }, { "netmask", required_argument, NULL, 'n' }, { "address", required_argument, NULL, 'A' }, { "write", required_argument, NULL, 'w' }, { "read", required_argument, NULL, 'r' }, { "pcapfilter", required_argument, NULL, 'f' }, { "reversed", no_argument, NULL, 'R' }, { "proto", required_argument, NULL, 't' }, { "plugin", required_argument, NULL, 'P' }, { "filter", required_argument, NULL, 'F' }, #ifdef HAVE_EC_LUA { "lua-script", required_argument, NULL, 0 }, { "lua-args", required_argument, NULL, 0 }, #endif { "superquiet", no_argument, NULL, 'Q' }, { "quiet", no_argument, NULL, 'q' }, { "script", required_argument, NULL, 's' }, { "silent", no_argument, NULL, 'z' }, #ifdef WITH_IPV6 { "ip6scan", no_argument, NULL, '6' }, #endif { "unoffensive", no_argument, NULL, 'u' }, { "nosslmitm", no_argument, NULL, 'S' }, { "load-hosts", required_argument, NULL, 'j' }, { "save-hosts", required_argument, NULL, 'k' }, { "wifi-key", required_argument, NULL, 'W' }, { "config", required_argument, NULL, 'a' }, { "dns", no_argument, NULL, 'd' }, { "regex", required_argument, NULL, 'e' }, { "visual", required_argument, NULL, 'V' }, { "ext-headers", no_argument, NULL, 'E' }, { "log", required_argument, NULL, 'L' }, { "log-info", required_argument, NULL, 'l' }, { "log-msg", required_argument, NULL, 'm' }, { "compress", no_argument, NULL, 'c' }, { "text", no_argument, NULL, 'T' }, { "curses", no_argument, NULL, 'C' }, { "daemon", no_argument, NULL, 'D' }, { "gtk", no_argument, NULL, 'G' }, { "mitm", required_argument, NULL, 'M' }, { "only-mitm", no_argument, NULL, 'o' }, { "bridge", required_argument, NULL, 'B' }, { "broadcast", required_argument, NULL, 'b' }, { "promisc", no_argument, NULL, 'p' }, { "gateway", required_argument, NULL, 'Y' }, { "certificate", required_argument, NULL, 0 }, { "private-key", required_argument, NULL, 0 }, { 0 , 0 , 0 , 0} }; for (c = 0; c < argc; c++) DEBUG_MSG("parse_options -- [%d] [%s]", c, argv[c]); /* OPTIONS INITIALIZATION */ GBL_PCAP->promisc = 1; GBL_FORMAT = &ascii_format; GBL_OPTIONS->ssl_mitm = 1; GBL_OPTIONS->broadcast = 0; GBL_OPTIONS->ssl_cert = NULL; GBL_OPTIONS->ssl_pkey = NULL; /* OPTIONS INITIALIZED */ optind = 0; int option_index = 0; while ((c = getopt_long (argc, argv, "A:a:bB:CchDdEe:F:f:GhIi:j:k:L:l:M:m:n:oP:pQqiRr:s:STt:uV:vW:w:Y:z6", long_options, &option_index)) != EOF) { /* used for parsing arguments */ char *opt_end = optarg; while (opt_end && *opt_end) opt_end++; /* enable a loaded filter script? */ switch (c) { case 'M': set_mitm(optarg); break; case 'o': set_onlymitm(); //select_text_interface(); break; case 'b': set_broadcast(); break; case 'B': set_iface_bridge(optarg); break; case 'p': set_promisc(); break; #ifndef JUST_LIBRARY case 'T': select_text_interface(); break; case 'C': select_curses_interface(); break; case 'G': select_gtk_interface(); break; case 'D': select_daemon_interface(); break; #endif case 'R': set_reversed(); break; case 't': set_proto(optarg); break; case 'P': set_plugin(optarg); break; case 'i': set_iface(optarg); break; case 'I': /* this option is only useful in the text interface */ set_lifaces(); break; case 'Y': set_secondary(optarg); break; case 'n': set_netmask(optarg); break; case 'A': set_address(optarg); break; case 'r': set_read_pcap(optarg); break; case 'w': set_write_pcap(optarg); break; case 'f': set_pcap_filter(optarg); break; case 'F': load_filter(opt_end, optarg); break; case 'L': set_loglevel_packet(optarg); case 'l': set_loglevel_info(optarg); break; case 'm': set_loglevel_true(optarg); break; case 'c': set_compress(); break; case 'e': opt_set_regex(optarg); break; case 'Q': set_superquiet(); /* no break, quiet must be enabled */ case 'q': set_quiet(); break; case 's': set_script(optarg); break; case 'z': set_silent(); break; #ifdef WITH_IPV6 case '6': set_ip6scan(); break; #endif case 'u': set_unoffensive(); break; case 'S': disable_sslmitm(); break; case 'd': set_resolve(); break; case 'j': load_hosts(optarg); break; case 'k': save_hosts(optarg); break; case 'V': opt_set_format(optarg); break; case 'E': set_ext_headers(); break; case 'W': set_wifi_key(optarg); break; case 'a': set_conf_file(optarg); break; case 'h': ec_usage(); break; case 'v': printf("%s %s\n", GBL_PROGRAM, GBL_VERSION); clean_exit(0); break; /* Certificate and private key options */ case 0: if (!strcmp(long_options[option_index].name, "certificate")) { GBL_OPTIONS->ssl_cert = strdup(optarg); } else if (!strcmp(long_options[option_index].name, "private-key")) { GBL_OPTIONS->ssl_pkey = strdup(optarg); #ifdef HAVE_EC_LUA } else if (!strcmp(long_options[option_index].name,"lua-args")) { ec_lua_cli_add_args(strdup(optarg)); } else if (!strcmp(long_options[option_index].name,"lua-script")) { ec_lua_cli_add_script(strdup(optarg)); break; #endif } else { fprintf(stdout, "\nTry `%s --help' for more options.\n\n", GBL_PROGRAM); clean_exit(-1); } break; case ':': // missing parameter fprintf(stdout, "\nTry `%s --help' for more options.\n\n", GBL_PROGRAM); clean_exit(-1); break; case '?': // unknown option fprintf(stdout, "\nTry `%s --help' for more options.\n\n", GBL_PROGRAM); clean_exit(-1); break; } } DEBUG_MSG("parse_options: options parsed"); /* TARGET1 and TARGET2 parsing */ if (argv[optind]) { GBL_OPTIONS->target1 = strdup(argv[optind]); DEBUG_MSG("TARGET1: %s", GBL_OPTIONS->target1); if (argv[optind+1]) { GBL_OPTIONS->target2 = strdup(argv[optind+1]); DEBUG_MSG("TARGET2: %s", GBL_OPTIONS->target2); } } /* create the list form the TARGET format (MAC/IPrange/PORTrange) */ compile_display_filter(); DEBUG_MSG("parse_options: targets parsed"); /* check for other options */ if (GBL_SNIFF->start == NULL) set_unified_sniff(); if (GBL_OPTIONS->read && GBL_PCAP->filter) FATAL_ERROR("Cannot read from file and set a filter on interface"); if (GBL_OPTIONS->read && GBL_SNIFF->type != SM_UNIFIED ) FATAL_ERROR("You can read from a file ONLY in unified sniffing mode !"); if (GBL_OPTIONS->mitm && GBL_SNIFF->type != SM_UNIFIED ) FATAL_ERROR("You can't do mitm attacks in bridged sniffing mode !"); if (GBL_SNIFF->type == SM_BRIDGED && GBL_PCAP->promisc == 0) FATAL_ERROR("During bridged sniffing the iface must be in promisc mode !"); if (GBL_OPTIONS->quiet && GBL_UI->type != UI_TEXT) FATAL_ERROR("The quiet option is useful only with text only UI"); if (GBL_OPTIONS->load_hosts && GBL_OPTIONS->save_hosts) FATAL_ERROR("Cannot load and save at the same time the hosts list..."); if (GBL_OPTIONS->unoffensive && GBL_OPTIONS->mitm) FATAL_ERROR("Cannot use mitm attacks in unoffensive mode"); if (GBL_OPTIONS->read && GBL_OPTIONS->mitm) FATAL_ERROR("Cannot use mitm attacks while reading from file"); #ifndef JUST_LIBRARY if (GBL_UI->init == NULL) FATAL_ERROR("Please select an User Interface"); #endif /* force text interface for only mitm attack */ /* Do not select text interface for only MiTM mode if (GBL_OPTIONS->only_mitm) { if (GBL_OPTIONS->mitm) select_text_interface(); else FATAL_ERROR("Only mitm requires at least one mitm method"); } */ DEBUG_MSG("parse_options: options combination looks good"); return; }