bool EventsMonitor::initialize(dictionary * configuration) { const char* uri = getStringProperty(configuration, monitorUri); EventsMonitor::host = getStringProperty(configuration, redisHost); EventsMonitor::port = getIntProperty(configuration, redisPort); EventsMonitor::machinePort = getStringProperty(configuration, serverPort); bool initialized = true; // connect to libvirt if (!connect(uri, callback)) { LOG("Unable to connect to hypervisor uri '%s'", uri); initialized = false; } if (initialized) { EventsMonitor::machineAddress = getIP(EventsMonitor::host, EventsMonitor::port); initialized = !EventsMonitor::machineAddress.empty(); } if (initialized) { LOG("Physical machine address is http://%s:%s", EventsMonitor::machineAddress.c_str(), EventsMonitor::machinePort.c_str()); } return initialized; }
bool HIDDeviceManager::initStrings(IOHIDDeviceRef device, HIDDeviceDesc* pDevDesc) { // Regardless of whether they fail we'll try and get the remaining. getStringProperty(device, CFSTR(kIOHIDManufacturerKey), &(pDevDesc->Manufacturer)); getStringProperty(device, CFSTR(kIOHIDProductKey), &(pDevDesc->Product)); return true; }
Atom ArrayObject::_getIntProperty(int index) const { if (index >= 0) return _getUintProperty(index); else // integer is negative - we must intern it return getStringProperty(core()->internInt(index)); }
void MLPluginProcessor::advancePreset(int amount) { int len = mPresetFiles->size(); std::string extension (".mlpreset"); int currIdx = - 1; currIdx = mPresetFiles->getFileIndexByName(getStringProperty("preset") + extension); if(currIdx >= 0) { currIdx += amount; } else { // not found currIdx = 0; } if(currIdx < 0) { currIdx = len - 1; } if(currIdx >= len) { currIdx = 0; } std::string relPath = mPresetFiles->getFileNameByIndex(currIdx); loadStateFromPath(relPath); }
void printEdgeProperties(int startID, Edge* e) { char* type; int weight; type = getStringProperty(0, e->propEdge); weight = getIntegerProperty(1,e->propEdge); printf("ID = %d --->%d %s %d\n",startID,e->endNodeID,type,weight); }
void printPersonProperties(Node* n) { char* name,*surname,*gender,*birthday,*creationDate,*locationIP,*browser; TagNode* temp; TagList* list; if(n == NULL) return; list = n->properties[7].property; name = getStringProperty(0, n->properties); surname = getStringProperty(1, n->properties); gender = getStringProperty(2, n->properties); birthday = getStringProperty(3, n->properties); creationDate = getStringProperty(4, n->properties); locationIP = getStringProperty(5, n->properties); browser = getStringProperty(6, n->properties); printf("id:%d,%s,%s,%s,%s,%s,%s,%s",n->id,name,surname,gender,birthday,creationDate,locationIP,browser); if(list!=NULL){ temp = list->head; while(temp!=NULL){ printf(",%d",temp->tag); temp =temp->next; } } printf("\n"); }
bool HIDDeviceManager::getSerialNumberString(IOHIDDeviceRef device, String* pResult) { if (!getStringProperty(device, CFSTR(kIOHIDSerialNumberKey), pResult)) { return false; } return true; }
bool Rimp::initialize(dictionary * configuration) { const char* repository_c = getStringProperty(configuration, rimpRepository); const char* autobackup_c = getStringProperty(configuration, rimpAutoBackup); const char* autorestore_c = getStringProperty(configuration, rimpAutoRestore); const char* rimpDatastoreValidTypes_c = getStringProperty(configuration, rimpDatastoreValidTypes); if (repository_c == NULL || strlen(repository_c) < 2) { LOG("[ERROR] [RIMP] Initialization fails :\n" "\tcan not read the ''repository'' configuration element " "\tset [rimp]\nrepository = XXXX "); return false; } autobackup = holdsTrueValue(autobackup_c); autorestore = holdsTrueValue(autorestore_c); repository = string(repository_c); // check ends with '/' if (repository.at(repository.size() - 1) != '/') { repository = repository.append("/"); } if(rimpDatastoreValidTypes_c == NULL) { validTypes = defaultValidTypeVector(); } else { boost::split(validTypes, rimpDatastoreValidTypes_c, boost::is_any_of(",")); } printValidTypes(validTypes); //return checkRepository(repository); // Don't check at start return true; }
// return true if the active GUI window is on the whitelist bool KeyboardPriority::checkForKeyboardPriority() { window_ = RootWindow(display, screen_); window_ = getLongProperty("_NET_ACTIVE_WINDOW"); // Compare the name of the active window to the white list std::string window_with_focus(reinterpret_cast<char*>( getStringProperty("WM_CLASS") )); for (int i=0; i<keyboard_whitelist_.size(); ++i) { if ( window_with_focus.find( keyboard_whitelist_[i] ) != std::string::npos ) return true; } // Otherwise this app should ignore the keyboard commands return false; }
Atom ScriptObject::getMultinameProperty(const Multiname* multiname) const { if (multiname->isValidDynamicName()) { return getStringProperty(multiname->getName()); } else { Toplevel* toplevel = this->toplevel(); if (multiname->isNsset()) toplevel->throwReferenceError(kReadSealedErrorNs, multiname, traits()); else toplevel->throwReferenceError(kReadSealedError, multiname, traits()); return undefinedAtom; } }
void NodeConfig::getInitiatorIQN(string& iqn) { dictionary* d = iniparser_load(iscsiInitiatorNameFile.c_str()); iqn = ""; if (d == NULL) { LOG("Unable to load %s. The IQN returned will be empty.", iscsiInitiatorNameFile.c_str()); } if (iniparser_find_entry(d, ":InitiatorName") != 0) { iqn = getStringProperty(d, ":InitiatorName"); } LOG("Request for node ISCSI initiator iqn = '%s'", iqn.c_str()); }
// auto-increment a version number and save at the current preset location with the new pathname. int MLPluginProcessor::saveStateAsVersion() { int r = 0; int version = 0; std::string nameStr(getStringProperty("preset")); std::string noVersionStr; std::string versionStr; int numberStart = 0; int digits = 0; // get version number int size = nameStr.size(); char c = nameStr[size - 1]; if(c == ']') { numberStart = size - 2; while((numberStart > 0) && isdigit(nameStr[numberStart])) { numberStart--; digits++; } numberStart++; noVersionStr = nameStr.substr(0, numberStart - 1); versionStr = nameStr.substr(numberStart, digits); version = atoi(versionStr.c_str()); } else { noVersionStr = nameStr; version = 0; } version++; version = clamp(version, 1, 9999); char vBuf[16]; sprintf(vBuf, "[%d]", version); std::string newName = noVersionStr + vBuf; saveStateToRelativePath(newName); r = 0; return r; }
bool HIDDeviceManager::getPath(IOHIDDeviceRef device, String* pPath) { String transport; if (!getStringProperty(device, CFSTR(kIOHIDTransportKey), &transport)) { return false; } UInt16 vendorId; if (!getVendorId(device, &vendorId)) { return false; } UInt16 productId; if (!getProductId(device, &productId)) { return false; } String serialNumber; if (!getSerialNumberString(device, &serialNumber)) { return false; } StringBuffer buffer; buffer.AppendFormat("%s:vid=%04hx:pid=%04hx:ser=%s", transport.ToCStr(), vendorId, productId, serialNumber.ToCStr()); *pPath = String(buffer); return true; }
void Toplevel::getWindowRole() { window_role = getStringProperty(window(), atoms->wm_window_role).toLower(); }
/*! Returns WM_COMMAND property for a given window. */ QByteArray Toplevel::staticWmCommand(xcb_window_t w) { return getStringProperty(w, XCB_ATOM_WM_COMMAND, ' '); }
int MLPluginProcessor::saveStateOverPrevious() { saveStateToRelativePath(getStringProperty("preset")); return 0; }
void MLPluginProcessor::getStateAsXML (XmlElement& xml) { if( !(mEngine.getCompileStatus() == MLProc::OK)) return; #if DEMO xml.setAttribute ("pluginVersion", JucePlugin_VersionCode); xml.setAttribute ("presetName", String("----")); #else const unsigned numParams = getNumParameters(); // TODO use string properties of model instead of these JUCE strings. // also move to JSON. xml.setAttribute ("pluginVersion", JucePlugin_VersionCode); xml.setAttribute ("presetName", String(getStringProperty("preset").c_str())); xml.setAttribute ("scaleName", String(getStringProperty("key_scale").c_str())); // store parameter values to xml as a bunch of attributes. // not XML best practice in general but takes fewer characters. for(unsigned i=0; i<numParams; ++i) { const String paramName = symbolToXMLAttr(getParameterAlias(i)); const float defaultVal = getParameterDefault(i); const float paramVal = getParameter(i); if (paramVal != defaultVal) { xml.setAttribute(paramName, paramVal); //debug() << "setting XML param " << paramName << " to " << paramVal << "\n"; } } // store patcher info to xml { MLProcList patchers = getPatcherList(); if (!patchers.empty()) { MLProcPatcher& firstPatcher = static_cast<MLProcPatcher&>(**patchers.begin()); const int inputs = firstPatcher.getParam("inputs"); const int outputs = firstPatcher.getParam("outputs"); String outStr; String patcherInput = "patcher_input_"; for(unsigned i=1; i<=inputs; ++i) { bool differentFromDefault = false; outStr = ""; for(unsigned j=1; j<=outputs; ++j) { if (firstPatcher.getConnection(i, j)) { outStr += "1"; differentFromDefault = true; } else { outStr += "0"; } } if(differentFromDefault) { String outNum (i); xml.setAttribute(patcherInput + outNum, outStr); } } } } // store editor state to XML if one exists MLPluginEditor* pEditor = static_cast<MLPluginEditor*>(getActiveEditor()); if(pEditor) { MLRect r = pEditor->getWindowBounds(); xml.setAttribute("editor_x", r.x()); xml.setAttribute("editor_y", r.y()); xml.setAttribute("editor_width", r.getWidth()); xml.setAttribute("editor_height", r.getHeight()); xml.setAttribute("editor_num", getFloatProperty("patch_num")); xml.setAttribute("editor_anim", getFloatProperty("patch_anim")); } // save blob as most recently saved state mpLatestStateLoaded = XmlElementPtr(new XmlElement(xml)); #endif }
/*! Returns SM_CLIENT_ID property for a given window. */ QByteArray Toplevel::staticSessionId(xcb_window_t w) { return getStringProperty(w, atoms->sm_client_id); }
unsigned long KeyboardPriority::getLongProperty(char* property_name) { unsigned char *prop = getStringProperty(property_name); unsigned long long_property = prop[0] + (prop[1]<<8) + (prop[2]<<16) + (prop[3]<<24); return long_property; }
//TODO keylist should be a list/set of string sets, because an operator may have more than one candidate key each of which may consist of multiple attributes void computeKeyProp (QueryOperator *root) { List *keyList = NIL; List *rKeyList = NIL; if (root == NULL) return; // compute key properties of children first if(root->inputs != NULL) FOREACH(QueryOperator, op, root->inputs) computeKeyProp(op); // table acces operator or constant relation operators have predetermined keys if(isA(root, TableAccessOperator)) { TableAccessOperator *rel = (TableAccessOperator *) root; keyList = getKeyInformation(rel->tableName); setStringProperty((QueryOperator *)root, PROP_STORE_LIST_KEY, (Node *)keyList); DEBUG_LOG("operator %s keys are {%s}", root->schema->name, stringListToString(keyList)); return; } else if (isA(root, ConstRelOperator)) { FOREACH(AttributeDef, a, root->schema->attrDefs) keyList = appendToTailOfList(keyList, strdup(a->attrName)); setStringProperty((QueryOperator *)root, PROP_STORE_LIST_KEY, (Node *)keyList); DEBUG_LOG("operator %s keys are {%s}", root->schema->name, stringListToString(keyList)); return; } // get keys of children keyList = (List *) getStringProperty(OP_LCHILD(root), PROP_STORE_LIST_KEY); if (IS_BINARY_OP(root)) { List *newKeyList = NIL; rKeyList = (List *) getStringProperty(OP_RCHILD(root), PROP_STORE_LIST_KEY); newKeyList = concatTwoLists(keyList, rKeyList); setStringProperty((QueryOperator *)root, PROP_STORE_LIST_KEY, (Node *)newKeyList); } // deal with different operator types // here we could use the ECs to determine new keys, e.g., if input has keys {{A}, {C}} and we have selection condition B = C, then we have a new key {{A}, {B}, {C}} if (isA(root, SelectionOperator)) setStringProperty((QueryOperator *)root, PROP_STORE_LIST_KEY, (Node *)keyList); if (isA(root, ProjectionOperator)) { List *l1 = ((ProjectionOperator *)root)->projExprs; List *l2 = NIL; FOREACH(AttributeReference, op1, l1) l2 = appendToTailOfList(l2, op1->name); FOREACH(char, op, keyList) { if(!searchListString(l2, op)) { setStringProperty((QueryOperator *)root, PROP_STORE_LIST_KEY, NULL); break; } setStringProperty((QueryOperator *)root, PROP_STORE_LIST_KEY, (Node *)keyList); } } // dup removal operator has a key {all attributes} if the input does not have a key if (isA(root, DuplicateRemoval)) { //List *l1 = getQueryOperatorAttrNames(OP_LCHILD(root)); //TODO Get the child's key property and Append it to above list and set it as property of duplicate operator setStringProperty((QueryOperator *)root, PROP_STORE_LIST_KEY, (Node *)keyList); } DEBUG_LOG("operator %s keys are {%s}", root->schema->name, stringListToString(keyList)); }