void debug_view_state::enumerate_sources() { // start with an empty list m_source_list.reset(); // iterate over devices that have state interfaces state_interface_iterator iter(machine().root_device()); std::string name; for (device_state_interface *state = iter.first(); state != NULL; state = iter.next()) { strprintf(name,"%s '%s'", state->device().name(), state->device().tag()); m_source_list.append(*global_alloc(debug_view_state_source(name.c_str(), state->device()))); } // reset the source to a known good entry set_source(*m_source_list.first()); }
void debug_view_state::enumerate_sources() { // start with an empty list m_source_list.reset(); // iterate over devices that have state interfaces device_state_interface *state = NULL; astring name; for (bool gotone = m_machine.m_devicelist.first(state); gotone; gotone = state->next(state)) { name.printf("%s '%s'", state->device().name(), state->device().tag()); m_source_list.append(*auto_alloc(m_machine, debug_view_state_source(name, state->device()))); } // reset the source to a known good entry set_source(*m_source_list.head()); }
void debug_view_breakpoints::enumerate_sources() { // start with an empty list m_source_list.reset(); // iterate over devices with disassembly interfaces disasm_interface_iterator iter(machine().root_device()); for (device_disasm_interface *dasm = iter.first(); dasm != nullptr; dasm = iter.next()) { std::string name; strprintf(name, "%s '%s'", dasm->device().name(), dasm->device().tag()); m_source_list.append(*global_alloc(debug_view_source(name.c_str(), &dasm->device()))); } // reset the source to a known good entry set_source(*m_source_list.first()); }
void debug_view_disasm::enumerate_sources() { // start with an empty list m_source_list.reset(); // iterate over devices with disassembly interfaces std::string name; for (device_disasm_interface &dasm : disasm_interface_iterator(machine().root_device())) { name = string_format("%s '%s'", dasm.device().name(), dasm.device().tag()); if (dasm.device().memory().space_config(AS_PROGRAM)!=nullptr) m_source_list.append(*global_alloc(debug_view_disasm_source(name.c_str(), dasm.device()))); } // reset the source to a known good entry set_source(*m_source_list.first()); }
void debug_view_watchpoints::enumerate_sources() { // start with an empty list m_source_list.reset(); // iterate over devices with disassembly interfaces disasm_interface_iterator iter(machine().root_device()); for (device_disasm_interface *dasm = iter.first(); dasm != NULL; dasm = iter.next()) { astring name; name.printf("%s '%s'", dasm->device().name(), dasm->device().tag()); m_source_list.append(*auto_alloc(machine(), debug_view_source(name.cstr(), &dasm->device()))); } // reset the source to a known good entry set_source(*m_source_list.head()); }
void debug_view_memory::enumerate_sources() { // start with an empty list m_source_list.reset(); std::string name; // first add all the devices' address spaces for (device_memory_interface &memintf : memory_interface_iterator(machine().root_device())) for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; ++spacenum) if (memintf.has_space(spacenum)) { address_space &space = memintf.space(spacenum); name = string_format("%s '%s' %s space memory", memintf.device().name(), memintf.device().tag(), space.name()); m_source_list.append(*global_alloc(debug_view_memory_source(name.c_str(), space))); } // then add all the memory regions for (auto ®ion : machine().memory().regions()) { name = string_format("Region '%s'", region.second->name()); m_source_list.append(*global_alloc(debug_view_memory_source(name.c_str(), *region.second.get()))); } // finally add all global array symbols for (int itemnum = 0; itemnum < 10000; itemnum++) { // stop when we run out of items u32 valsize, valcount; void *base; const char *itemname = machine().save().indexed_item(itemnum, base, valsize, valcount); if (itemname == nullptr) break; // add pretty much anything that's not a timer (we may wish to cull other items later) // also, don't trim the front of the name, it's important to know which VIA6522 we're looking at, e.g. if (strncmp(itemname, "timer/", 6)) { name.assign(itemname); m_source_list.append(*global_alloc(debug_view_memory_source(name.c_str(), base, valsize, valcount))); } } // reset the source to a known good entry set_source(*m_source_list.first()); }
MaterialShaderMethod& MaterialShaderMethod::load_from_json(std::string const& json_string) { Json::Value value; Json::Reader reader; if (!reader.parse(json_string, value)) { Logger::LOG_WARNING << "Failed to parse material method description: " "Invalid json String!" << std::endl; return *this; } if (value["name"] != Json::Value::null && value["source"] != Json::Value::null) { set_name(value["name"].asString()); set_source(value["source"].asString()); if (value["uniforms"] != Json::Value::null && value["uniforms"].isArray()) { for (int i(0); i < value["uniforms"].size(); ++i) { auto uniform_string(value["uniforms"][i]); if (uniform_string["name"] != Json::Value::null && uniform_string["type"] != Json::Value::null && uniform_string["value"] != Json::Value::null) { auto uniform(UniformValue::create_from_strings( uniform_string["value"].asString(), uniform_string["type"].asString() )); set_uniform(uniform_string["name"].asString(), ViewDependentUniform(uniform)); } else { Logger::LOG_WARNING << "Failed to load uniform: " "Please provide name, type and value in the description!" << std::endl; } } } } else { Logger::LOG_WARNING << "Failed to load material method: " "Please provide name and source in the description!" << std::endl; } return *this; }
bool XMLtoJSONInternal::nextImpl( store::Item_t& result, PlanState &planState ) const { store::Item_t xml_item; options_type options; PlanIteratorState *state; DEFAULT_STACK_INIT( PlanIteratorState, state, planState ); ZORBA_ASSERT( theChildren.size() == 2 ); consumeNext( xml_item, theChildren[1], planState ); get_options( xml_item, &options ); consumeNext( xml_item, theChildren[0], planState ); try { options_type::mapped_type const &format_opt = options[ "json-format" ]; ZORBA_ASSERT( !format_opt.empty() ); switch ( xml_item->getNodeKind() ) { case store::StoreConsts::elementNode: if ( format_opt == "Snelson" ) snelson::xml_to_json( xml_item, &result ); else if ( format_opt == "JsonML" || format_opt == "JsonML-array" ) jsonml_array::xml_to_json( xml_item, &result ); else if ( format_opt == "JsonML-object" ) jsonml_object::xml_to_json( xml_item, &result ); else ZORBA_ASSERT( false ); break; default: throw XQUERY_EXCEPTION( zerr::ZJSE0001_NOT_ELEMENT_NODE, ERROR_LOC( loc ) ); } // switch } catch ( ZorbaException &e ) { set_source( e, loc ); throw; } STACK_PUSH( !!result, state ); STACK_END( state ); }
ret_code_t fumi_block_setsource(void) { SaHpiBankNumT banknum; SaHpiTextBufferT uri; if ( get_banknum( &banknum) != HPI_SHELL_OK ) { return HPI_SHELL_PARM_ERROR; } if ( get_uri( &uri) != HPI_SHELL_OK ) { return HPI_SHELL_PARM_ERROR; } return set_source( Domain->sessionId, fumi_block_env.rptid, fumi_block_env.fuminum, banknum, &uri ); }
z_status zp_parser::parse_obj(void* p_obj,const zp_factory* factory,ctext data) { z_status status; Z_ASSERT(p_obj); set_source(data,strlen(data)); reset_results(); factory->clear_all_vars(p_obj); context_set_root(p_obj,factory,0); status=_process_template(zp_mode_parse_input); if(status==zs_matched) { ZT("==========ITEM[%s] MATCHED, CREATING=====\n",factory->get_name()); index_reset(); context_get_current_template_parser().index_reset(); reset_results(); status=_process_template(zp_mode_parse_create); } return status; }
LocalZipTask::LocalZipTask(rc_ptr<ThreadPool> tp, TimerManager *tmgr, rc_ptr<XmlElement> config) : AbstractSyncTask(tp, tmgr) { assert(tp.is_not_null() && NULL != tmgr && config.is_not_null()); const string& name = config->get_name(); set_name(QString::fromLocal8Bit(name.data(), name.length())); rc_ptr<XmlElement> x = config->get_child("source"); if (x.is_not_null()) { const string& text = x->get_text(); set_source(QString::fromLocal8Bit(text.data(), text.length())); } else { NUT_LOG_E("plugin.syncer.localzip", "source path is missing for task %s", get_name().toLocal8Bit().data()); } x = config->get_child("destination"); if (x.is_not_null()) { const string text = x->get_text(); set_destination(QString::fromLocal8Bit(text.data(), text.length())); } else { NUT_LOG_E("plugin.syncer.localzip", "destination path is missing for task %s", get_name().toLocal8Bit().data()); } x = config->get_child("timer"); if (x.is_not_null()) { const string text = x->get_text(); const time_t secs = QString::fromLocal8Bit(text.data(), text.length()).toLong(); set_timer_interval(secs); } start_timer(); }
bool obs_transition_start(obs_source_t *transition, enum obs_transition_mode mode, uint32_t duration_ms, obs_source_t *dest) { bool active; bool same_as_source; bool same_as_dest; if (!transition_valid(transition, "obs_transition_start")) return false; lock_transition(transition); same_as_source = dest == transition->transition_sources[0]; same_as_dest = dest == transition->transition_sources[1]; active = transition_active(transition); unlock_transition(transition); if (same_as_source && !active) return false; if (transition->transition_use_fixed_duration) duration_ms = transition->transition_fixed_duration; if (!active || (!same_as_dest && !same_as_source)) { transition->transition_start_time = os_gettime_ns(); transition->transition_duration = (uint64_t)duration_ms * 1000000ULL; } set_source(transition, OBS_TRANSITION_SOURCE_B, dest, activate_transition); obs_source_dosignal(transition, "source_transition_start", "transition_start"); /* TODO: Add mode */ UNUSED_PARAMETER(mode); return true; }
bool MultiplyOperation::compute<store::XS_DT_DURATION,store::XS_DOUBLE>( store::Item_t& result, dynamic_context* dctx, const TypeManager* tm, const QueryLoc* loc, const store::Item* i0, const store::Item* i1) { std::unique_ptr<Duration> d; if ( i1->getDoubleValue().isPosInf() || i1->getDoubleValue().isNegInf() ) throw XQUERY_EXCEPTION( err::FODT0002, ERROR_LOC( loc ) ); else if (i1->getDoubleValue().isNaN()) throw XQUERY_EXCEPTION( err::FOCA0005, ERROR_LOC( loc ) ); else try { d.reset(i0->getDayTimeDurationValue() * (i1->getDoubleValue())); } catch (XQueryException& e) { set_source(e, *loc); throw; } return GENV_ITEMFACTORY->createDayTimeDuration(result, d.get()); }
bool InCollectionPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const { store::Item_t lUri; PlanIteratorState *state; DEFAULT_STACK_INIT(PlanIteratorState, state, planState); consumeNext(lUri, theChildren[0].getp(), planState); try { GENV_ITEMFACTORY->createBoolean(result, lUri->inCollection()); } catch (ZorbaException& e) { set_source(e, loc); throw; } STACK_PUSH(true,state); STACK_END (state); }
bool LevelPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const { store::Item_t lUri; PlanIteratorState *state; DEFAULT_STACK_INIT(PlanIteratorState, state, planState); consumeNext(lUri, theChildren[0].getp(), planState); try { result = lUri->getLevel(); } catch (ZorbaException& e) { set_source(e, loc); throw; } STACK_PUSH(true, state); STACK_END (state); }
/** this function loads the settings for volume and source from the eeprom * and restores the settings. sets volume and source to the last saved state */ void restore_settings(void) { AMP_ENABLE = 0; /** mute power amplifier */ uint8_t temp;//, temp1; temp = recall_source(); if ((temp == 0xFF)||(temp<SOURCE_MIN)||(temp>SOURCE_MAX)) /** default value from empty eeprom or illegal value */ temp = SOURCE_MIN; /** set useful value */ set_source(temp); /** if there is a value stored, restore it */ get_source(temp); /** send restored value to the source switching function */ temp = recall_volume(1); /** used twice */ if ((temp == 0xFF)||(temp<VOLUME_MAX)||(temp>VOLUME_MIN)) /** default value from empty eeprom or illegal value */ temp = VOLUME_MIN; /** set useful value */ // temp1=recall_volume(0); /** recall value for left volume; currently not in use */ // if (temp1 == 0xFF) /** default value from empty eeprom */ // temp1 = VOLUME_MIN; /** set useful value */ set_volume(temp,temp); /** set recalled volume value */ get_volume(0,temp); /** send volume setting to volume changing function */ }
CMatGsuBoard::CMatGsuBoard() : CMatBase(s_grid_size, s_grid_size) { auto ctx = get_ctx(); // grids ctx->set_source(SolidPattern::create_rgba(0, 0, 0, 0.01)); for (int i = 0; i < s_grid_size; ++i) { for (int j = 0; j < s_grid_size; ++j) { ctx->move_to(i, 1); ctx->line_to(i, s_grid_size-1); ctx->move_to(1, j); ctx->line_to(s_grid_size-1, j); ctx->stroke(); } } ctx->save(); ctx->translate(s_grid_size/2, s_grid_size/2); // 1. background color auto pat = gw_create_solidpat({0, 0, 0}); ctx->set_source(pat); // center rectangle ctx->rectangle(-2,-2, 4,4); ctx->rectangle(-3, -3, 6, 6); ctx->stroke(); // v line ctx->move_to(0, -6); ctx->line_to(0, 9); ctx->stroke(); // h line ctx->move_to(-9, 0); ctx->line_to(9, 0); ctx->stroke(); // player home for (int i = 0; i < 3; ++i) { ctx->save(); ctx->rotate(M_PI * 0.5 * i); for (int i = 4; i < 7; ++i) { ctx->move_to(i, -1); ctx->line_to(i, 1); } ctx->rectangle(7, -1, 2, 2); ctx->move_to(8, -1); ctx->line_to(8, 1); ctx->stroke(); ctx->restore(); } // award for (int i = 4; i < 7; ++i) { ctx->move_to(-1, -i); ctx->line_to(1, -i); } ctx->stroke(); ctx->restore(); // cross points ctx->set_source(SolidPattern::create_rgba(0, 1, 1, 0.2)); for (int y = 0; y <= s_grid_size; ++y) { for (int x = 0; x <= s_grid_size; ++x) { if (points[y][x] == 1) { ctx->arc(x, y, 0.5, 0, M_PI * 2); ctx->fill(); } } } return; }
void AudioPlayer::set_source(std::string _audio_name){ set_source(AllAudioSources::get_cur_object()->get(_audio_name)->get_buffer()); }
void external_function::serialize(::zorba::serialization::Archiver& ar) { zorba::serialization::serialize_baseclass(ar, (function*)this); ar & theNamespace; ar & theScriptingKind; // also serialize the localname of the function zstring lLocalName; if (ar.is_serializing_out()) { computeCacheSettings(NULL); ZORBA_ASSERT(theImpl); lLocalName = Unmarshaller::getInternalString(theImpl->getLocalName()); } ar.set_is_temp_field(true); ar & lLocalName; ar.set_is_temp_field(false); // if loaded, theImpl needs to be set immediately // this is covered by test/unit/external_function.cpp if (!ar.is_serializing_out()) { try { theImpl = theModuleSctx->lookup_external_function(theNamespace, lLocalName); } catch (XQueryException& e) { set_source( e, theLoc ); throw; } if (theImpl == NULL) { RAISE_ERROR(zerr::ZXQP0008_FUNCTION_IMPL_NOT_FOUND, theLoc, ERROR_PARAMS(BUILD_STRING( '{', theNamespace, '}', lLocalName))); } } ar & theLoc; ar & theHasCache; ar & theCacheAcrossSnapshots; if (ar.is_serializing_out()) { saveFlags(theExcludeFromCacheKey, ar); saveFlags(theCompareWithDeepEqual, ar); } else { loadFlags(theExcludeFromCacheKey, ar); loadFlags(theCompareWithDeepEqual, ar); } ar & theAreCacheSettingsComputed; ar & theIsCacheAutomatic; if (!ar.is_serializing_out()) { theCache.reset(new FunctionCache( theModuleSctx, theExcludeFromCacheKey, theCompareWithDeepEqual, theCacheAcrossSnapshots)); } }
void normalizeInputUri( zstring const& aUri, static_context* aSctx, QueryLoc const& aLoc, zstring* aResult) { zstring const lBaseUri = aSctx->get_base_uri(); try { // To support the very common (if technically incorrect) use // case of users passing local filesystem paths to fn:doc(), // we use the following heuristic: IF the base URI has a file: // scheme AND the incoming URI has no scheme, we will assume // the incoming URI is actually a filesystem path. QQQ For // the moment, we assume any "unknown" schemes are probably // Windows drive letters. if ((uri::get_scheme(aUri) == uri::none || uri::get_scheme(aUri) == uri::unknown) && uri::get_scheme(lBaseUri) == uri::file) { try { // Ok, we assume it's a filesystem path. First normalize it. zstring lNormalizedPath = fs::normalize_path( aUri ); // QQQ For now, normalize_path() doesn't do what we // want when base URI represents a file. So, when the // normalized path is relative, we pretend it's a relative // URI and resolve it as such. if (fs::is_absolute(lNormalizedPath)) { URI::encode_file_URI(lNormalizedPath, *aResult); } else { #ifdef WIN32 ascii::replace_all(lNormalizedPath, '\\', '/'); #endif *aResult = aSctx->resolve_relative_uri(lNormalizedPath, true); } } catch ( std::invalid_argument const &e ) { throw XQUERY_EXCEPTION( err::XPTY0004, ERROR_PARAMS( e.what() ) ); } } else { // We do NOT assume it's a filesystem path; just resolve it. *aResult = aSctx->resolve_relative_uri(aUri, true); } } catch (ZorbaException& e) { if (e.diagnostic() == err::XQST0046) // the value of a URILiteral is of nonzero length and is not in the // lexical space of xs:anyURI. e.set_diagnostic(err::FODC0005); else e.set_diagnostic(err::FODC0002); set_source(e, aLoc); throw; } }
void ConvectionDiffusionBase<TDomain>:: set_source(LuaFunctionHandle fct) { set_source(make_sp(new LuaUserData<number,dim>(fct))); }
Deal& from(const DistributedSubAccount& dsa) { set_source(dsa); return *this; }
void ConvectionDiffusionBase<TDomain>:: set_source(number val) { if(val == 0.0) set_source(SmartPtr<CplUserData<number, dim> >()); else set_source(make_sp(new ConstUserNumber<dim>(val))); }
void ConvectionDiffusionBase<TDomain>:: set_source(const char* fctName) { set_source(LuaUserDataFactory<number,dim>::create(fctName)); }
void shader_object::set_source_from_file ( std::string filename ) { std::string shader_source{}; ASL::files::append_file_to_string ( filename, shader_source ); set_source ( shader_source ); }
int main(int argc, char *argv[]) { int sd = 0, opt, print_pkt = 0, fix_cks = 0, status; static char *opstring = "czhpa:e:d:t:i:f:o:"; if (argc == 1) { usage(argv[0]); exit(-1); } while ((opt = getopt(argc, argv, opstring)) != -1) { switch (opt) { case ('i'): status = set_source(ETHERNET_NIC, optarg); printf("Source: live NIC %s\n", optarg); if (status != 1) { printf("Error setting input\n"); exit(-2); } sd = create_set(); break; case ('f'): status = set_source(TCPDUMP_TRACE, optarg); printf("Source: pcap file %s\n", optarg); if (status != 1) { printf("Error setting input\n"); exit(-2); } sd = create_set(); break; case ('e'): if (strcmp(optarg, "ZERO") == 0) { add_function(sd, "ANONYMIZE", ETHERNET, SRC_IP, ZERO); add_function(sd, "ANONYMIZE", ETHERNET, DST_IP, ZERO); printf("Zero ethernet addresses\n"); } break; case ('a'): if (strcmp(optarg, "MAP") == 0) { add_function(sd, "ANONYMIZE", IP, SRC_IP, MAP); add_function(sd, "ANONYMIZE", IP, DST_IP, MAP); printf("Map ip addresses\n"); } else if (strcmp(optarg, "PREFIX") == 0) { add_function(sd, "ANONYMIZE", IP, SRC_IP, PREFIX_PRESERVING); add_function(sd, "ANONYMIZE", IP, DST_IP, PREFIX_PRESERVING); printf("Prefix-preserving ip addresses\n"); } else { add_function(sd, "ANONYMIZE", IP, SRC_IP, ZERO); add_function(sd, "ANONYMIZE", IP, DST_IP, ZERO); printf("Zero ip addresses\n"); } break; case ('p'): print_pkt = 1; break; case ('d'): if (strcmp(optarg, "STRIP") == 0) { add_function(sd, "ANONYMIZE", TCP, PAYLOAD, STRIP, 0); add_function(sd, "ANONYMIZE", UDP, PAYLOAD, STRIP, 0); printf("Removing TCP payload\n"); } else if (strcmp(optarg, "HASH") == 0) { add_function(sd, "ANONYMIZE", TCP, PAYLOAD, HASHED, MD5, STRIP_REST); add_function(sd, "ANONYMIZE", UDP, PAYLOAD, HASHED, MD5, STRIP_REST); printf("HASH TCP/UDP payload\n"); } else { add_function(sd, "ANONYMIZE", TCP, PAYLOAD, ZERO); add_function(sd, "ANONYMIZE", UDP, PAYLOAD, ZERO); printf("ZERO TCP payload\n"); } break; case ('h'): usage(argv[0]); exit(0); break; case ('t'): if (strcmp(optarg, "MAP") == 0) { add_function(sd, "ANONYMIZE", TCP, SRC_PORT, MAP); add_function(sd, "ANONYMIZE", TCP, DST_PORT, MAP); printf("Map TCP ports\n"); } else { add_function(sd, "ANONYMIZE", TCP, SRC_PORT, ZERO); add_function(sd, "ANONYMIZE", TCP, DST_PORT, ZERO); printf("ZERO TCP ports\n"); } break; case ('z'): add_function(sd, "ANONYMIZE", IP, OPTIONS, ZERO); add_function(sd, "ANONYMIZE", TCP, TCP_OPTIONS, RANDOM); printf("Zero TCP and IP options\n"); break; case ('c'): fix_cks = 1; printf("Fix checksums\n"); break; default: usage(argv[0]); exit(0); break; } } status = set_output(sd, TCPDUMP_TRACE, argv[argc - 1]); printf("Output: File %s\n\n", argv[argc - 1]); if (status != 1) { printf("Error setting output\n"); exit(-2); } if (fix_cks) add_function(sd, "ANONYMIZE", IP, CHECKSUM, CHECKSUM_ADJUST); if (print_pkt) add_function(sd, "PRINT_PACKET"); printf("\nStart anonymize...\n"); start_processing(); printf("End anonymize\n"); return EXIT_SUCCESS; }
/* * do_action() * * This routine attaches a new existing action to a source object, * where possible. * The action will not do anything until it is LINKed. * */ void do_action(int descr, dbref player, const char *action_name, const char *source_name) { dbref action, source; static char buf[BUFFER_LEN]; char buf2[BUFFER_LEN]; char *rname, *qname; if (!Builder(player)) { anotify_nolisten2(player, CFAIL NOBBIT_MESG); return; } if (!tp_building || tp_db_readonly) { anotify_nolisten2(player, CFAIL NOBUILD_MESG); return; } strcpy(buf2, source_name); for (rname = buf2; (*rname && (*rname != '=')); rname++) ; qname = rname; if (*rname) *(rname++) = '\0'; while ((qname > buf2) && (isspace(*qname))) *(qname--) = '\0'; qname = buf2; for (; *rname && isspace(*rname); rname++) ; if (!*action_name || !*qname) { anotify_nolisten2(player, CINFO "You must specify an action name and a source object."); return; } else if (!ok_name(action_name)) { anotify_nolisten2(player, CINFO "That's a strange name for an action!"); return; } if (((source = parse_source(descr, player, qname)) == NOTHING)) return; if (!payfor(player, tp_exit_cost)) { anotify_fmt(player, SYSRED "You don't have enough %s to make an action.", tp_pennies); return; } action = new_object(player); NAME(action) = alloc_string(action_name); DBFETCH(action)->location = NOTHING; OWNER(action) = OWNER(player); DBFETCH(action)->sp.exit.ndest = 0; DBFETCH(action)->sp.exit.dest = NULL; FLAGS(action) = TYPE_EXIT; set_source(player, action, source); sprintf(buf, CSUCC "Action %s created and attached to %s.", unparse_object(player, action), NAME(source)); anotify_nolisten2(player, buf); DBDIRTY(action); if (*rname) { PData pdat; sprintf(buf, CINFO "Registered as $%s", rname); anotify_nolisten2(player, buf); sprintf(buf, "_reg/%s", rname); pdat.flags = PROP_REFTYP; pdat.data.ref = action; set_property(player, buf, &pdat); } if (tp_autolinking) { DBFETCH(action)->sp.exit.ndest = 1; DBFETCH(action)->sp.exit.dest = (dbref *) malloc(sizeof(dbref)); (DBFETCH(action)->sp.exit.dest)[0] = NIL; sprintf(buf, CINFO "Linked to NIL."); anotify_nolisten2(player, buf); } }
int main (int argc, char **argv) { int c; unsigned short port = 0; binding_t *source = 0; binding_t *dest = 0; binding_t *s, *d; char packet[8192]; int n; int i; int nsource; int soopts; int verbose = 0; int source_set = 0; int dest_set = 0; struct pollfd *fds; while ((c = getopt (argc, argv, "vp:s:d:")) >= 0) { switch (c) { case 'p': port = atoi (optarg); if (port <= 0) usage (argv[0]); break; case 's': s = make_binding (optarg); s->next = source; source = s; break; case 'd': d = make_binding (optarg); d->next = dest; dest = d; break; case 'v': verbose++; break; default: usage (argv[0]); break; } } if (!port || !source || !dest) usage (argv[0]); nsource = 0; for (s = source; s; s = s->next) { set_source (s, port); if (verbose) dump_addr (s->fd, "source", 0); nsource++; } if (nsource > 1) { fds = malloc (nsource * sizeof (struct pollfd)); if (!fds) losing (argv[0], "malloc fds"); i = 0; for (s = source; s; s = s->next) { fds[i].fd = s->fd; fds[i].events = POLLIN; fds[i].revents = 0; } } else fds = 0; for (d = dest; d; d = d->next) { set_dest (d, port); if (verbose) dump_addr (d->fd, "dest", 1); } /* spend a while shipping packets around */ for (;;) { if (fds) { i = poll (fds, nsource, -1); if (i < 0) break; } i = 0; for (s = source, i = 0; s; s = s->next, i++) { if (!fds || fds[i].revents & POLLIN) { n = read (s->fd, packet, sizeof (packet)); if (n < 0) losing (argv[0], "read"); if (verbose) fprintf (stderr, "%d\n", n ); for (d = dest; d; d = d->next) { if (write (d->fd, packet, n) < n) losing (argv[0], "write"); } } } } }
AudioPlayer& AudioPlayer::operator=(const AudioPlayer &that){ set_source(that.buffer); return *this; }