bool CheckRequireAuth() { NoRegistry registry(this); if (!m_bAuthenticated && registry.value(NV_REQUIRE_AUTH).toBool()) { network()->setEnabled(false); putModule("Disabling network, we require authentication."); putModule("Use 'RequireAuth no' to disable."); return true; } return false; }
int nfs_unshare(char *bp, char *host){ char **vals = calloc(3,sizeof(char*)); int ret; vals[0] = bp; vals[1] = host; ret = registry(REG_DELETE, table, NULL, vals); free(vals); return ret; }
void Authenticate(const NoString& line) { if (m_Mechanisms.GetCurrent().equals("PLAIN") && line.equals("+")) { NoRegistry registry(this); NoString line = registry.value("username") + '\0' + registry.value("username") + '\0' + registry.value("password"); line = line.toBase64(); putIrc("AUTHENTICATE " + line); } else { /* Send blank authenticate for other mechanisms (like EXTERNAL). */ putIrc("AUTHENTICATE +"); } }
/* mark root set */ static void markroot (lua_State *L) { global_State *g = G(L); g->gray = NULL; g->grayagain = NULL; g->weak = NULL; markobject(g, g->mainthread); /* make global table be traversed before main stack */ markvalue(g, gt(g->mainthread)); markvalue(g, registry(L)); markmt(g); g->gcstate = GCSpropagate; }
/* ** open parts that may cause memory-allocation errors */ static void f_luaopen (lua_State *L, void *ud) { global_State *g = G(L); UNUSED(ud); stack_init(L, L); /* init stack */ sethvalue(L, gt(L), luaH_new(L, 0, 2)); /* table of globals */ sethvalue(L, registry(L), luaH_new(L, 0, 2)); /* registry */ luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ luaT_init(L); luaX_init(L); luaS_fix(luaS_newliteral(L, MEMERRMSG)); g->GCthreshold = 4*g->totalbytes; }
TEST_F(CustomElementRegistryTest, lookupCustomElementDefinition) { NonThrowableExceptionState shouldNotThrow; TestCustomElementDefinitionBuilder builder; CustomElementDefinition* definitionA = registry().define( "a-a", builder, ElementDefinitionOptions(), shouldNotThrow); ElementDefinitionOptions options; options.setExtends("div"); CustomElementDefinition* definitionB = registry().define("b-b", builder, options, shouldNotThrow); // look up defined autonomous custom element CustomElementDefinition* definition = registry().definitionFor( CustomElementDescriptor(CustomElementDescriptor("a-a", "a-a"))); EXPECT_NE(nullptr, definition) << "a-a, a-a should be registered"; EXPECT_EQ(definitionA, definition); // look up undefined autonomous custom element definition = registry().definitionFor(CustomElementDescriptor("a-a", "div")); EXPECT_EQ(nullptr, definition) << "a-a, div should not be registered"; // look up defined customized built-in element definition = registry().definitionFor(CustomElementDescriptor("b-b", "div")); EXPECT_NE(nullptr, definition) << "b-b, div should be registered"; EXPECT_EQ(definitionB, definition); // look up undefined customized built-in element definition = registry().definitionFor(CustomElementDescriptor("a-a", "div")); EXPECT_EQ(nullptr, definition) << "a-a, div should not be registered"; }
bool WindowsPlatformIntegration::setAsDefaultBrowser() { if (!isBrowserRegistered() && !registerToSystem()) { return false; } QSettings registry(QLatin1String("HKEY_CURRENT_USER\\Software"), QSettings::NativeFormat); for (int i = 0; i < m_registrationPairs.count(); ++i) { if (m_registrationPairs.at(i).second == ProtocolType) { registry.setValue(QLatin1String("Classes/") + m_registrationPairs.at(i).first + QLatin1String("/DefaultIcon/."), m_applicationFilePath + QLatin1String(",1")); registry.setValue(QLatin1String("Classes/") + m_registrationPairs.at(i).first + QLatin1String("/shell/open/command/."), QLatin1String("\"") + m_applicationFilePath + QLatin1String("\" \"%1\"")); } else { registry.setValue(QLatin1String("Classes/") + m_registrationPairs.at(i).first + QLatin1String("/."), m_registrationIdentifier); } } registry.setValue(QLatin1String("Clients/StartmenuInternet/."), m_registrationIdentifier); registry.sync(); if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) { IApplicationAssociationRegistrationUI *applicationAssociationRegistrationUI = NULL; HRESULT result = CoCreateInstance(CLSID_ApplicationAssociationRegistrationUI, NULL, CLSCTX_INPROC_SERVER, IID_IApplicationAssociationRegistrationUI, (LPVOID*)&applicationAssociationRegistrationUI); if (result == S_OK && applicationAssociationRegistrationUI) { result = applicationAssociationRegistrationUI->LaunchAdvancedAssociationUI(m_registrationIdentifier.toStdWString().c_str()); applicationAssociationRegistrationUI->Release(); if (result == S_OK) { return true; } } Console::addMessage(QCoreApplication::translate("main", "Failed to run File Associations Manager, error code: %1").arg(result), Otter::OtherMessageCategory, ErrorMessageLevel); } else { SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_DWORD | SHCNF_FLUSH, NULL, NULL); Sleep(1000); } return true; }
Ioss::Transform* Factory::create(const std::string& type) { Ioss::Transform *transform = NULL; FactoryMap::iterator iter = registry()->find(type); if (iter == registry()->end()) { if (registry()->size() == 0) { std::ostringstream errmsg; errmsg << "FATAL: No transformations have been registered.\n" << " Was Iotr::Initializer::initialize() called?\n\n"; IOSS_ERROR(errmsg); } else { std::ostringstream errmsg; errmsg << "FATAL: The transform named '" << type << "' is not supported.\n"; IOSS_ERROR(errmsg); } } else { Factory* factory = (*iter).second; transform = factory->make(type); } return transform; }
int nfs_share(char *bp, char *host, char *params){ char **vals = calloc(3,sizeof(char*)); int ret; vals[0] = bp; vals[1] = host; vals[2] = params ? params : NFS_DEFAULT_PARAMS; ret = registry(REG_REPLACE, table, NULL, vals); free(vals); return ret; }
TObject *negindex (lua_State *L, int idx) { if (idx > LUA_REGISTRYINDEX) { api_check(L, idx != 0 && -idx <= L->top - L->base); return L->top+idx; } else if (idx < -40000) { return (TObject*)luaH_getnum(hvalue(registry(L)), -idx - 40000); } else switch (idx) { /* pseudo-indices */ case LUA_REGISTRYINDEX: return registry(L); case LUA_GLOBALSINDEX: return gt(L); default: { TObject *func = (L->base - 1); idx = LUA_GLOBALSINDEX - idx; lua_assert(iscfunction(func)); return (idx <= clvalue(func)->c.nupvalues) ? &clvalue(func)->c.upvalue[idx-1] : NULL; } } }
turntable::turntable(SpeedController& j, DigitalInput& l, DigitalInput& m, DigitalInput& r) { jag = &j; left = &l; mid = &m; right = &r; registry().register_func(update_help, (void*)this); power = 0.0; //enable by default enabled = true; centering = false; pos = UNSURE; }
TEST_F(CustomElementRegistryTest, collectCandidates_shouldBeInDocumentOrder) { CreateElement factory = CreateElement("a-a"); factory.inDocument(&document()); Element* elementA = factory.withId("a"); Element* elementB = factory.withId("b"); Element* elementC = factory.withId("c"); registry().addCandidate(elementB); registry().addCandidate(elementA); registry().addCandidate(elementC); document().documentElement()->appendChild(elementA); elementA->appendChild(elementB); document().documentElement()->appendChild(elementC); HeapVector<Member<Element>> elements; collectCandidates(CustomElementDescriptor("a-a", "a-a"), &elements); EXPECT_EQ(elementA, elements[0].get()); EXPECT_EQ(elementB, elements[1].get()); EXPECT_EQ(elementC, elements[2].get()); }
void RequireAuthCommand(const NoString& line) { NoRegistry registry(this); if (!No::token(line, 1).empty()) { registry.setValue(NV_REQUIRE_AUTH, No::token(line, 1)); } if (registry.value(NV_REQUIRE_AUTH).toBool()) { putModule("We require SASL negotiation to connect"); } else { putModule("We will connect even if SASL fails"); } }
TEST_F(CustomElementRegistryTest, collectCandidates_oneCandidate) { Element* element = CreateElement("a-a").inDocument(&document()); registry().addCandidate(element); document().documentElement()->appendChild(element); HeapVector<Member<Element>> elements; collectCandidates(CustomElementDescriptor("a-a", "a-a"), &elements); EXPECT_EQ(1u, elements.size()) << "exactly one candidate should have been found"; EXPECT_TRUE(elements.contains(element)) << "the candidate should be the element that was added"; }
bool MainWindow::findSkype() { bool found = false; QSettings registry("HKEY_CURRENT_USER\\Software\\Skype\\Phone", QSettings::NativeFormat); QVariant path = registry.value("SkypePath"); if(path.isValid()) { skype_path = path.toString().prepend('"').append('"'); found = true; } else { QSettings registry("HKEY_LOCAL_MACHINE\\Software\\Skype\\Phone", QSettings::NativeFormat); QVariant path = registry.value("SkypePath"); if(path.isValid()) { skype_path = path.toString().prepend('"').append('"'); found = true; } } return found; }
/** * Writes a value to the registry * @param szRegValue Name of the value that should be written * @param Pos Value that should be written */ bool Registry::Set(const TCHAR *szRegValue, const TCHAR *Pos) { #ifdef WIN32 RegistryKey registry(HKEY_CURRENT_USER, szProfileKey, false); return !registry.error() && registry.set_value(szRegValue, Pos); #else /* !WIN32 */ return GConf().set(szRegValue, Pos); #endif /* !WIN32 */ }
LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { int i; lua_State *L; global_State *g; void *l = (*f)(ud, NULL, 0, state_size(LG)); if (l == NULL) return NULL; L = tostate(l); g = &((LG *)L)->g; L->next = NULL; L->tt = LUA_TTHREAD; g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT); L->marked = luaC_white(g); set2bits(L->marked, FIXEDBIT, SFIXEDBIT); preinit_state(L, g); g->frealloc = f; g->ud = ud; g->mainthread = L; g->uvhead.u.l.prev = &g->uvhead; g->uvhead.u.l.next = &g->uvhead; g->GCthreshold = 0; /* mark it as unfinished state */ g->strt.size = 0; g->strt.nuse = 0; g->strt.hash = NULL; setnilvalue(registry(L)); luaZ_initbuffer(L, &g->buff); g->panic = NULL; g->gcstate = GCSpause; g->rootgc = obj2gco(L); g->sweepstrgc = 0; g->sweepgc = &g->rootgc; g->gray = NULL; g->grayagain = NULL; g->weak = NULL; g->tmudata = NULL; g->totalbytes = sizeof(LG); g->gcpause = LUAI_GCPAUSE; g->gcstepmul = LUAI_GCMUL; g->gcdept = 0; g->disablegc = 0; g->printfunc = default_printfunc; g->printfuncdata = NULL; for (i=0; i<NUM_TAGS; i++) g->mt[i] = NULL; if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) { /* memory allocation error: free partial state */ close_state(L); L = NULL; } else luai_userstateopen(L); return L; }
TEST_F(CustomElementRegistryTest, collectCandidates_shouldNotIncludeElementsRemovedFromDocument) { Element* element = CreateElement("a-a").inDocument(&document()); registry().addCandidate(element); HeapVector<Member<Element>> elements; collectCandidates(CustomElementDescriptor("a-a", "a-a"), &elements); EXPECT_TRUE(elements.isEmpty()) << "no candidates should have been found, but we have " << elements.size(); EXPECT_FALSE(elements.contains(element)) << "the out-of-document candidate should not have been found"; }
TEST_F(CustomElementRegistryTest, adoptedCallback) { ScriptForbiddenScope doNotRelyOnScript; Element* element = CreateElement("a-a").inDocument(&document()); document().documentElement()->appendChild(element); LogUpgradeBuilder builder; NonThrowableExceptionState shouldNotThrow; { CEReactionsScope reactions; registry().define("a-a", builder, ElementDefinitionOptions(), shouldNotThrow); } LogUpgradeDefinition* definition = static_cast<LogUpgradeDefinition*>(registry().definitionForName("a-a")); definition->clear(); Document* otherDocument = HTMLDocument::create(); { CEReactionsScope reactions; otherDocument->adoptNode(element, ASSERT_NO_EXCEPTION); } EXPECT_EQ(LogUpgradeDefinition::DisconnectedCallback, definition->m_logs[0]) << "adoptNode() should invoke disconnectedCallback"; EXPECT_EQ(LogUpgradeDefinition::AdoptedCallback, definition->m_logs[1]) << "adoptNode() should invoke adoptedCallback"; EXPECT_EQ(&document(), definition->m_adopted[0]->m_oldOwner.get()) << "adoptedCallback should have been passed the old owner document"; EXPECT_EQ(otherDocument, definition->m_adopted[0]->m_newOwner.get()) << "adoptedCallback should have been passed the new owner document"; EXPECT_EQ(2u, definition->m_logs.size()) << "adoptNode() should not invoke other callbacks"; }
bool IsWidcommDevice(const TCHAR *name) { TCHAR key[64]; if (!FindDevice(name, key, 64)) return false; RegistryKey registry(HKEY_LOCAL_MACHINE, key, true); if (registry.error()) return false; TCHAR dll[64]; return registry.get_value(_T("Dll"), dll, 64) && _tcscmp(dll, _T("btcedrivers.dll")); }
/* mark root set */ static void markroot (lua_State *L) { global_State *g = G(L); g->gray = NULL; g->grayagain = NULL; g->weak = NULL; markobject(g, g->mainthread); /* make global table be traversed before main stack */ markvalue(g, gt(g->mainthread)); markvalue(g, registry(L)); #if LUA_FASTREF_SUPPORT markvalue(g, &G(L)->l_refs); #endif /* LUA_FASTREF_SUPPORT */ markmt(g); g->gcstate = GCSpropagate; }
LLSD LLCommandDispatcher::enumerate() { LLSD response; LLCommandHandlerRegistry& registry(LLCommandHandlerRegistry::instance()); for (std::map<std::string, LLCommandHandlerInfo>::const_iterator chi(registry.mMap.begin()), chend(registry.mMap.end()); chi != chend; ++chi) { LLSD info; info["untrusted"] = chi->second.mUntrustedBrowserAccess; info["untrusted_str"] = lookup(chi->second.mUntrustedBrowserAccess); response[chi->first] = info; } return response; }
MachODylibFile* MachOLinkingContext::loadIndirectDylib(StringRef path) { ErrorOr<std::unique_ptr<MemoryBuffer>> mbOrErr = getMemoryBuffer(path); if (mbOrErr.getError()) return nullptr; ErrorOr<std::unique_ptr<File>> fileOrErr = registry().loadFile(std::move(mbOrErr.get())); if (!fileOrErr) return nullptr; std::unique_ptr<File> &file = fileOrErr.get(); file->parse(); MachODylibFile *result = reinterpret_cast<MachODylibFile *>(file.get()); // Node object now owned by _indirectDylibs vector. _indirectDylibs.push_back(std::move(file)); return result; }
Language::Language( String displayName, RegExp pathPattern, const SyntaxDefinition *highlightingSyntax, const SyntaxDefinition *discoverySyntax, const SyntaxDefinition *foldingSyntax ) : displayName_(displayName), name_(highlightingSyntax->name()), pathPattern_(pathPattern), highlightingSyntax_(highlightingSyntax), discoverySyntax_(discoverySyntax), foldingSyntax_(foldingSyntax) { registry()->registerLanguage(this); }
void TestQgsColorSchemeRegistry::removeScheme() { //create an empty registry QSharedPointer<QgsColorSchemeRegistry> registry( new QgsColorSchemeRegistry() ); QVERIFY( registry->schemes().length() == 0 ); //add a scheme QgsColorScheme *recentScheme = new QgsRecentColorScheme(); registry->addColorScheme( recentScheme ); QVERIFY( registry->schemes().length() == 1 ); //remove the scheme QVERIFY( registry->removeColorScheme( recentScheme ) ); QVERIFY( registry->schemes().length() == 0 ); //try removing a scheme not in the registry QVERIFY( !registry->removeColorScheme( recentScheme ) ); delete recentScheme; }
Status RegistryFactory::callTable(const std::string& table_name, QueryContext& context, PluginResponse& response) { auto& tables = registry("table")->items_; // This only works for local tables. if (tables.count(table_name) > 0) { auto plugin = std::dynamic_pointer_cast<TablePlugin>(tables.at(table_name)); response = plugin->generate(context); return Status(0); } else { // If the table is not local then it does not benefit from complex contexts. PluginRequest request = {{"action", "generate"}}; TablePlugin::setRequestFromContext(context, request); return call("table", table_name, request, response); } }
/* mark root set */ static void markroot (lua_State *L) { global_State *g = G(L); g->gray = NULL; g->grayagain = NULL; g->weak = NULL; markobject(g, g->mainthread); /* make global table be traversed before main stack */ markvalue(g, gt(g->mainthread)); markvalue(g, registry(L)); markmt(g); #if LUAPLUS_EXTENSIONS if (G(L)->userGCFunction) G(L)->userGCFunction(L); #endif /* LUAPLUS_EXTENSIONS */ g->gcstate = GCSpropagate; }
bool Ioss::VariableType::build_variable_type(const std::string& raw_type) { // See if this is a multi-component instance of a base type. // An example would be REAL[2] which is a basic real type with // two components. The suffices would be .0 and .1 std::string type = Ioss::Utils::lowercase(raw_type); // Step 0: // See if the type contains '[' and ']' char const *typestr = type.c_str(); char const *lbrace = std::strchr(typestr, '['); char const *rbrace = std::strrchr(typestr, ']'); if (lbrace == NULL || rbrace == NULL) return false; // Step 1: // First, we split off the basename (REAL/INTEGER) from the component count ([2]) // and see if the basename is a valid variable type and the count is a // valid integer. size_t len = type.length() + 1; char *typecopy = new char[len]; std::strcpy(typecopy, typestr); char *base = std::strtok(typecopy, "[]"); assert (base != NULL); Ioss::VariableTypeMap::iterator iter = Ioss::VariableType::registry().find(base); if (iter == registry().end()) { delete [] typecopy; return false; } char *countstr = std::strtok(NULL, "[]"); assert (countstr != NULL); int count = std::atoi(countstr); if (count <= 0) { delete [] typecopy; return false; } // We now know we have a valid base type and an integer // specifying the number of 'components' in our new type. // Create the new type and register it in the registry... new Ioss::ConstructedVariableType(type, count, true); delete [] typecopy; return true; }
ptrdiff_t lj_vmevent_prepare(lua_State *L, VMEvent ev) { global_State *g = G(L); GCstr *s = lj_str_newlit(L, LJ_VMEVENTS_REGKEY); cTValue *tv = lj_tab_getstr(tabV(registry(L)), s); if (tvistab(tv)) { int hash = VMEVENT_HASH(ev); tv = lj_tab_getint(tabV(tv), hash); if (tv && tvisfunc(tv)) { lj_state_checkstack(L, LUA_MINSTACK); setfuncV(L, L->top++, funcV(tv)); return savestack(L, L->top); } } g->vmevmask &= ~VMEVENT_MASK(ev); /* No handler: cache this fact. */ return 0; }
void OptionBase::help(const std::string& description) { if (!description.empty()) { std::cerr << description << '\n'; std::cerr << '\n'; } std::cerr << "USAGE\n"; std::cerr << std::left; for (auto i : registry()) { std::cerr << " -" << std::setw(18) << i.first << std::setw(20) << i.second->string() << i.second->description() << '\n'; } }