//static LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) { LLFloater* res = findInstance(name, key); if (!res) { const LLFloaterBuildFunc& build_func = sBuildMap[name].mFunc; // const std::string& xui_file = sBuildMap[name].mFile; // [SL:KB] - Patch: UI-Base | Checked: 2010-12-01 (Catznip-3.0.0a) | Added: Catznip-2.5.0a const std::string& xui_file = (!sBuildMap[name].mFileFunc) ? sBuildMap[name].mFile : sBuildMap[name].mFileFunc(); // [/SL:KB] if (build_func) { const std::string& groupname = sGroupMap[name]; if (!groupname.empty()) { instance_list_t& list = sInstanceMap[groupname]; res = build_func(key); if (!res) { LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL; return NULL; } bool success = res->buildFromFile(xui_file); if (!success) { LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL; return NULL; } // Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe if (res->mKey.isUndefined()) { res->mKey = key; } res->setInstanceName(name); LLFloater *last_floater = (list.empty() ? NULL : list.back()); res->applyControlsAndPosition(last_floater); gFloaterView->adjustToFitScreen(res, false); list.push_back(res); } } if (!res) { LL_WARNS() << "Floater type: '" << name << "' not registered." << LL_ENDL; } } return res; }
//static LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) { LLFloater* res = findInstance(name, key); if (!res) { const LLFloaterBuildFunc& build_func = sBuildMap[name].mFunc; const std::string& xui_file = sBuildMap[name].mFile; if (build_func) { const std::string& groupname = sGroupMap[name]; if (!groupname.empty()) { instance_list_t& list = sInstanceMap[groupname]; int index = list.size(); res = build_func(key); bool success = res->buildFromFile(xui_file, NULL); if (!success) { llwarns << "Failed to build floater type: '" << name << "'." << llendl; return NULL; } // Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe res->mKey = key; res->setInstanceName(name); res->applySavedVariables(); // Can't apply rect and dock state until setting instance name if (res->mAutoTile && !res->getHost() && index > 0) { const LLRect& cur_rect = res->getRect(); LLRect next_rect = getFloaterRect(groupname); next_rect.setLeftTopAndSize(next_rect.mLeft, next_rect.mTop, cur_rect.getWidth(), cur_rect.getHeight()); res->setRect(next_rect); res->setRectControl(LLStringUtil::null); // don't save rect of tiled floaters gFloaterView->adjustToFitScreen(res, true); } else { gFloaterView->adjustToFitScreen(res, false); } list.push_back(res); } } if (!res) { llwarns << "Floater type: '" << name << "' not registered." << llendl; } } return res; }
/** * Collect all external state that is relevant for compiling the given * fragment program. */ static void build_state( r300ContextPtr r300, struct r300_fragment_program *fp, struct r300_fragment_program_external_state *state) { int unit; _mesa_bzero(state, sizeof(*state)); for(unit = 0; unit < 16; ++unit) { if (fp->mesa_program.Base.ShadowSamplers & (1 << unit)) { struct gl_texture_object* tex = r300->radeon.glCtx->Texture.Unit[unit]._Current; state->unit[unit].depth_texture_mode = build_dtm(tex->DepthMode); state->unit[unit].texture_compare_func = build_func(tex->CompareFunc); } } }
//static LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) { LLFloater* res = findInstance(name, key); if (!res) { const LLFloaterBuildFunc& build_func = sBuildMap[name].mFunc; const std::string& xui_file = sBuildMap[name].mFile; if (build_func) { const std::string& groupname = sGroupMap[name]; if (!groupname.empty()) { instance_list_t& list = sInstanceMap[groupname]; int index = list.size(); res = build_func(key); bool success = res->buildFromFile(xui_file, NULL); if (!success) { llwarns << "Failed to build floater type: '" << name << "'." << llendl; return NULL; } // Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe res->mKey = key; res->setInstanceName(name); // AO: Mark certain floaters (sidebar tab floaters) as needing to be pseudo-hidden on minimization. // At the moment we flag this pseudo hiding with the presence of a dummy control in floater_side_bar_tab.xml // and the name of the floater window. This should be refactored into a floater attribute. llinfos << "trying to restore variables for name: " << name << llendl; std::string pat = "side_bar_tab"; size_t found = name.find(pat); if (found!=std::string::npos) { if (!res->hasChild("showMinimized")) res->setHideOnMinimize(true); } res->applySavedVariables(); // Can't apply rect and dock state until setting instance name if (res->mAutoTile && !res->getHost() && index > 0) { const LLRect& cur_rect = res->getRect(); LLRect next_rect = getFloaterRect(groupname); next_rect.setLeftTopAndSize(next_rect.mLeft, next_rect.mTop, cur_rect.getWidth(), cur_rect.getHeight()); res->setRect(next_rect); res->setRectControl(LLStringUtil::null); // don't save rect of tiled floaters gFloaterView->adjustToFitScreen(res, true); } else { gFloaterView->adjustToFitScreen(res, false); } list.push_back(res); } } if (!res) { llwarns << "Floater type: '" << name << "' not registered." << llendl; } } return res; }
/* * scamper_probe_send * * this meta-function is responsible for * 1. sending a probe * 2. handling any error condition incurred when sending the probe * 3. recording details of the probe with the trace's state */ int scamper_probe(scamper_probe_t *probe) { int (*send_func)(scamper_probe_t *) = NULL; int (*build_func)(scamper_probe_t *, uint8_t *, size_t *) = NULL; size_t pad, len; uint8_t *buf; probe->pr_errno = 0; probe_print(probe); /* determine which function scamper should use to build or send the probe */ if(probe->pr_ip_dst->type == SCAMPER_ADDR_TYPE_IPV4) { if((probe->pr_ip_off & IP_OFFMASK) != 0) { build_func = scamper_ip4_frag_build; } else if(probe->pr_ip_proto == IPPROTO_UDP) { send_func = scamper_udp4_probe; build_func = scamper_udp4_build; } else if(probe->pr_ip_proto == IPPROTO_TCP) { build_func = scamper_tcp4_build; if(probe->pr_fd != -1) send_func = scamper_tcp4_probe; } else if(probe->pr_ip_proto == IPPROTO_ICMP) { send_func = scamper_icmp4_probe; build_func = scamper_icmp4_build; } } else if(probe->pr_ip_dst->type == SCAMPER_ADDR_TYPE_IPV6) { if(probe->pr_ip_off != 0) { build_func = scamper_ip6_frag_build; } else if(probe->pr_ip_proto == IPPROTO_UDP) { send_func = scamper_udp6_probe; build_func = scamper_udp6_build; } else if(probe->pr_ip_proto == IPPROTO_TCP) { build_func = scamper_tcp6_build; } else if(probe->pr_ip_proto == IPPROTO_ICMPV6) { send_func = scamper_icmp6_probe; build_func = scamper_icmp6_build; } } /* if we're not using the datalink to send the packet, then send it now */ if(probe->pr_dl == NULL) { if(send_func != NULL) return send_func(probe); probe->pr_errno = EINVAL; return -1; } /* if the header type is not known (we cannot build it) then bail */ if(build_func == NULL) { probe->pr_errno = EINVAL; return -1; } /* * determine a suitable value for the length parameter for passing * to build_func. to do so we also need to calculate the number of pad * bytes to put at the front of the packet buffer so that the IP layer * is properly aligned for the architecture */ pad = PAD(probe->pr_dl_len); if(pad + probe->pr_dl_len >= pktbuf_len) len = 0; else len = pktbuf_len - pad - probe->pr_dl_len; /* * try building the probe. if it returns -1, then hopefully the len field * will supply a clue as to what it should be */ if(build_func(probe, pktbuf + pad + probe->pr_dl_len, &len) != 0) { assert(pktbuf_len < pad + probe->pr_dl_len + len); /* reallocate the packet buffer */ len += pad + probe->pr_dl_len; if((buf = realloc(pktbuf, len)) == NULL) { probe->pr_errno = errno; printerror(errno, strerror, __func__, "could not realloc"); return -1; } pktbuf = buf; pktbuf_len = len; len = pktbuf_len - pad - probe->pr_dl_len; if(build_func(probe, pktbuf + pad + probe->pr_dl_len, &len) != 0) { probe->pr_errno = EINVAL; return -1; } } /* add the datalink header size back to the length field */ len += probe->pr_dl_len; /* pre-pend the datalink header, if there is one */ if(probe->pr_dl_len > 0) memcpy(pktbuf+pad, probe->pr_dl_buf, probe->pr_dl_len); gettimeofday_wrap(&probe->pr_tx); if(scamper_dl_tx(probe->pr_dl, pktbuf+pad, len) == -1) { probe->pr_errno = errno; return -1; } probe->pr_tx_raw = pktbuf + pad + probe->pr_dl_len; probe->pr_tx_rawlen = len - probe->pr_dl_len; return 0; }
/* * probe_build * * determine how to build the packet and call the appropriate function * to do so. */ static probe_t *probe_build(scamper_probe_t *pr) { int (*build_func)(scamper_probe_t *, uint8_t *, size_t *) = NULL; probe_t *pt = NULL; size_t len; if(SCAMPER_ADDR_TYPE_IS_IPV4(pr->pr_ip_dst)) { if((pr->pr_ip_off & IP_OFFMASK) != 0) build_func = scamper_ip4_frag_build; else if(pr->pr_ip_proto == IPPROTO_UDP) build_func = scamper_udp4_build; else if(pr->pr_ip_proto == IPPROTO_ICMP) build_func = scamper_icmp4_build; else if(pr->pr_ip_proto == IPPROTO_TCP) build_func = scamper_tcp4_build; } else if(SCAMPER_ADDR_TYPE_IS_IPV6(pr->pr_ip_dst)) { if(pr->pr_ip_off != 0) build_func = scamper_ip6_frag_build; if(pr->pr_ip_proto == IPPROTO_UDP) build_func = scamper_udp6_build; else if(pr->pr_ip_proto == IPPROTO_ICMPV6) build_func = scamper_icmp6_build; else if(pr->pr_ip_proto == IPPROTO_TCP) build_func = scamper_tcp6_build; } if(build_func == NULL) { pr->pr_errno = EINVAL; goto err; } /* allow 16 bytes at the front of the packet for layer-2 headers */ if(16 >= pktbuf_len) len = 0; else len = pktbuf_len-16; if(build_func(pr, pktbuf+16, &len) != 0) { /* reallocate the packet buffer */ if(realloc_wrap((void **)&pktbuf, len+16) != 0) { pr->pr_errno = errno; goto err; } pktbuf_len = len+16; if(build_func(pr, pktbuf+16, &len) != 0) { pr->pr_errno = EINVAL; goto err; } } if((pt = malloc_zero(sizeof(probe_t))) == NULL) { pr->pr_errno = errno; goto err; } pt->buf = pktbuf; pt->len = len; return pt; err: return NULL; }