//! \brief Saves the library to a file. bool Library::saveLibrary() { QString saveText; Qucs::XmlWriter *writer = new Qucs::XmlWriter(&saveText); writer->setAutoFormatting(true); writer->writeStartDocument(); writer->writeStartElement("library"); writer->writeAttribute("name", libraryName()); writer->writeAttribute("version", Qucs::version); writer->writeStartElement("displaytext"); writer->writeLocaleText("en", displayText()); writer->writeEndElement(); //</displaytext> writer->writeStartElement("description"); writer->writeLocaleText("en", description()); writer->writeEndElement(); //</description> //Save all components in library QList<ComponentDataPtr> componentsList = components().values(); foreach(const ComponentDataPtr data, componentsList) { writer->writeEmptyElement("component"); writer->writeAttribute("href", QFileInfo(data->filename).fileName()); }
void BacktraceLineGdb::rate() { LineRating r; //for explanations, see the LineRating enum definition if (!fileName().isEmpty()) { r = Good; } else if (!libraryName().isEmpty()) { if (functionName() == "??") { r = MissingFunction; } else { r = MissingSourceFile; } } else { if (functionName() == "??") { r = MissingEverything; } else { r = MissingLibrary; } } d->m_rating = r; }
cimSLPService getSLPData(cimomConfig cfg, const CMPIBroker *_broker, const CMPIContext *ctx, const char *urlsyntax) { CMPIInstance **ci; //CMPIStatus status; //CMPIConstClass *ccls; cimSLPService rs; // service which is going to be returned // to the calling function char *sn; #ifdef SLP_HOSTNAME_LIB static void *hostnameLib = NULL; static getSlpHostname gethostname; char *ln; char dlName[512]; int err; err = 1; if (getControlChars("slpHostnamelib", &ln) == 0) { libraryName(NULL, ln, dlName, 512); if ((hostnameLib = dlopen(dlName, RTLD_LAZY))) { gethostname = dlsym(hostnameLib, "_sfcGetSlpHostname"); if (gethostname) err = 0; } } if (err) mlogf(M_ERROR, M_SHOW, "--- SLP Hostname exit %s not found. Defaulting to system hostname.\n", dlName); #endif _SFCB_ENTER(TRACE_SLP, "getSLPData"); memset(&rs, 0, sizeof(cimSLPService)); // first of all, get the interop namespace, needed for all further // connections // this call fills the array as well as sets the global interOpNS // variable rs.InteropSchemaNamespace = getInterOpNS(); // extract all relavant stuff for SLP out of CIM_ObjectManager // construct the server string ci = myGetInstances(_broker, ctx, interOpNS, "CIM_ObjectManager", urlsyntax); if (ci) { sn = myGetProperty(ci[0], "SystemName"); #ifdef SLP_HOSTNAME_LIB if (!err) { char *tmp; if ((err = gethostname(&tmp))) { free(sn); sn = tmp; } else { printf ("-#- SLP call to %s for hostname failed. Defaulting to system hostname.\n", dlName); } } #endif rs.url_syntax = getUrlSyntax(sn, cfg.commScheme, cfg.port); rs.service_hi_name = myGetProperty(ci[0], "ElementName"); rs.service_hi_description = myGetProperty(ci[0], "Description"); rs.service_id = myGetProperty(ci[0], "Name"); freeInstArr(ci); } // extract all relavant stuff for SLP out of // CIM_ObjectManagerCommunicationMechanism ci = myGetInstances(_broker, ctx, interOpNS, "CIM_ObjectManagerCommunicationMechanism", urlsyntax); if (ci) { rs.CommunicationMechanism = myGetProperty(ci[0], "CommunicationMechanism"); rs.OtherCommunicationMechanismDescription = myGetProperty(ci[0], "OtherCommunicationMechanism"); rs.ProtocolVersion = myGetProperty(ci[0], "Version"); rs.FunctionalProfilesSupported = myGetPropertyArray(ci[0], "FunctionalProfilesSupported"); rs.FunctionalProfileDescriptions = myGetPropertyArray(ci[0], "FunctionalProfileDescriptions"); rs.MultipleOperationsSupported = myGetProperty(ci[0], "MultipleOperationsSupported"); rs.AuthenticationMechanismsSupported = myGetPropertyArray(ci[0], "AuthenticationMechanismsSupported"); rs.AuthenticationMechansimDescriptions = myGetPropertyArray(ci[0], "AuthenticationMechansimDescriptions"); // do the transformations from numbers to text via the qualifiers //CMPIStatus myRc; //CMPIObjectPath *myOp = CMGetObjectPath(ci[0], &myRc); //CMPIData qd = CMGetPropertyQualifier(myOp, "CommunicationMechanism", "ValueMap", &myRc); rs.CommunicationMechanism = transformValue(rs.CommunicationMechanism, CMGetObjectPath(ci[0], NULL), "CommunicationMechanism"); rs.FunctionalProfilesSupported = transformValueArray(rs.FunctionalProfilesSupported, CMGetObjectPath(ci[0], NULL), "FunctionalProfilesSupported"); rs.AuthenticationMechanismsSupported = transformValueArray(rs.AuthenticationMechanismsSupported, CMGetObjectPath(ci[0], NULL), "AuthenticationMechanismsSupported"); freeInstArr(ci); } // extract all relavant stuff for SLP out of CIM_Namespace ci = myGetInstances(_broker, ctx, interOpNS, "CIM_Namespace", urlsyntax); if (ci) { rs.Namespace = myGetPropertyArrayFromArray(ci, "Name"); rs.Classinfo = myGetPropertyArrayFromArray(ci, "ClassInfo"); freeInstArr(ci); } // extract all relavant stuff for SLP out of CIM_RegisteredProfile //CMPIContext *ctxLocal = prepareUpcall(ctx); //ci = myGetInstances(_broker, ctxLocal, interOpNS, "CIM_RegisteredProfile", urlsyntax); ci = myGetInstances(_broker, ctx, interOpNS, "CIM_RegisteredProfile", urlsyntax); if (ci) { rs.RegisteredProfilesSupported = myGetRegProfiles(_broker, ci, ctx); //rs.RegisteredProfilesSupported = myGetRegProfiles(_broker, ci, ctxLocal); freeInstArr(ci); } //CMRelease(ctxLocal); _SFCB_RETURN(rs); }
void CmpSeabaseDDL::dropSeabaseLibrary(StmtDDLDropLibrary * dropLibraryNode, NAString &currCatName, NAString &currSchName) { Lng32 cliRC = 0; Lng32 retcode = 0; const NAString &objName = dropLibraryNode->getLibraryName(); ComObjectName libraryName(objName); ComAnsiNamePart currCatAnsiName(currCatName); ComAnsiNamePart currSchAnsiName(currSchName); libraryName.applyDefaults(currCatAnsiName, currSchAnsiName); const NAString catalogNamePart = libraryName. getCatalogNamePartAsAnsiString(); const NAString schemaNamePart = libraryName. getSchemaNamePartAsAnsiString(TRUE); const NAString objectNamePart = libraryName. getObjectNamePartAsAnsiString(TRUE); const NAString extLibraryName = libraryName.getExternalName(TRUE); ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, CmpCommon::context()->sqlSession()->getParentQid()); ExpHbaseInterface * ehi = allocEHI(); if (ehi == NULL) return; retcode = existsInSeabaseMDTable(&cliInterface, catalogNamePart, schemaNamePart, objectNamePart, COM_LIBRARY_OBJECT, TRUE, FALSE); if (retcode < 0) { deallocEHI(ehi); processReturn(); return; } if (retcode == 0) // does not exist { *CmpCommon::diags() << DgSqlCode(-1389) << DgString0(extLibraryName); deallocEHI(ehi); processReturn(); return; } Int32 objectOwnerID = 0; Int32 schemaOwnerID = 0; Int64 objectFlags = 0; Int64 objUID = getObjectInfo(&cliInterface, catalogNamePart.data(), schemaNamePart.data(), objectNamePart.data(), COM_LIBRARY_OBJECT, objectOwnerID,schemaOwnerID,objectFlags); if (objUID < 0 || objectOwnerID == 0 || schemaOwnerID == 0) { deallocEHI(ehi); processReturn(); return; } if (!isDDLOperationAuthorized(SQLOperation::DROP_LIBRARY, objectOwnerID, schemaOwnerID)) { *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED); processReturn (); return; } Queue * usingRoutinesQueue = NULL; cliRC = getUsingRoutines(&cliInterface, objUID, usingRoutinesQueue); if (cliRC < 0) { deallocEHI(ehi); processReturn(); return; } // If RESTRICT and the library is being used, return an error if (cliRC != 100 && dropLibraryNode->getDropBehavior() == COM_RESTRICT_DROP_BEHAVIOR) { *CmpCommon::diags() << DgSqlCode(-CAT_DEPENDENT_ROUTINES_EXIST); deallocEHI(ehi); processReturn(); return; } for (size_t i = 0; i < usingRoutinesQueue->numEntries(); i++) { usingRoutinesQueue->position(); OutputInfo * rou = (OutputInfo*)usingRoutinesQueue->getNext(); char * routineName = rou->get(0); ComObjectType objectType = PrivMgr::ObjectLitToEnum(rou->get(1)); if (dropSeabaseObject(ehi, routineName, currCatName, currSchName, objectType, TRUE, FALSE)) { deallocEHI(ehi); processReturn(); return; } } // can get a slight perf. gain if we pass in objUID if (dropSeabaseObject(ehi, objName, currCatName, currSchName, COM_LIBRARY_OBJECT, TRUE, FALSE)) { deallocEHI(ehi); processReturn(); return; } deallocEHI(ehi); processReturn(); return; }
void CmpSeabaseDDL::createSeabaseLibrary( StmtDDLCreateLibrary * createLibraryNode, NAString &currCatName, NAString &currSchName) { Lng32 retcode = 0; ComObjectName libraryName(createLibraryNode->getLibraryName()); ComAnsiNamePart currCatAnsiName(currCatName); ComAnsiNamePart currSchAnsiName(currSchName); libraryName.applyDefaults(currCatAnsiName, currSchAnsiName); const NAString catalogNamePart = libraryName.getCatalogNamePartAsAnsiString(); const NAString schemaNamePart = libraryName.getSchemaNamePartAsAnsiString(TRUE); const NAString objectNamePart = libraryName.getObjectNamePartAsAnsiString(TRUE); const NAString extLibraryName = libraryName.getExternalName(TRUE); const NAString extNameForHbase = catalogNamePart + "." + schemaNamePart + "." + objectNamePart; // Verify that the requester has MANAGE_LIBRARY privilege. if (isAuthorizationEnabled() && !ComUser::isRootUserID()) { NAString privMgrMDLoc; CONCAT_CATSCH(privMgrMDLoc, getSystemCatalog(), SEABASE_PRIVMGR_SCHEMA); PrivMgrComponentPrivileges componentPrivileges(std::string(privMgrMDLoc.data()),CmpCommon::diags()); if (!componentPrivileges.hasSQLPriv (ComUser::getCurrentUser(),SQLOperation::MANAGE_LIBRARY,true)) { *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED); processReturn (); return; } } // Check to see if user has the authority to create the library ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, CmpCommon::context()->sqlSession()->getParentQid()); Int32 objectOwnerID = SUPER_USER; Int32 schemaOwnerID = SUPER_USER; ComSchemaClass schemaClass; retcode = verifyDDLCreateOperationAuthorized(&cliInterface, SQLOperation::CREATE_LIBRARY, catalogNamePart, schemaNamePart, schemaClass, objectOwnerID, schemaOwnerID); if (retcode != 0) { handleDDLCreateAuthorizationError(retcode,catalogNamePart,schemaNamePart); return; } ExpHbaseInterface * ehi = NULL; ehi = allocEHI(); if (ehi == NULL) { processReturn(); return; } retcode = existsInSeabaseMDTable(&cliInterface, catalogNamePart, schemaNamePart, objectNamePart, COM_LIBRARY_OBJECT, TRUE, FALSE); if (retcode < 0) { deallocEHI(ehi); processReturn(); return; } if (retcode == 1) // already exists { *CmpCommon::diags() << DgSqlCode(-1390) << DgString0(extLibraryName); deallocEHI(ehi); processReturn(); return; } NAString libFileName = createLibraryNode->getFilename() ; // strip blank spaces libFileName = libFileName.strip(NAString::both, ' '); if (validateLibraryFileExists(libFileName, FALSE)) { deallocEHI(ehi); processReturn(); return; } ComTdbVirtTableTableInfo * tableInfo = new(STMTHEAP) ComTdbVirtTableTableInfo[1]; tableInfo->tableName = NULL, tableInfo->createTime = 0; tableInfo->redefTime = 0; tableInfo->objUID = 0; tableInfo->objOwnerID = objectOwnerID; tableInfo->schemaOwnerID = schemaOwnerID; tableInfo->isAudited = 1; tableInfo->validDef = 1; tableInfo->hbaseCreateOptions = NULL; tableInfo->numSaltPartns = 0; tableInfo->rowFormat = COM_UNKNOWN_FORMAT_TYPE; tableInfo->objectFlags = 0; Int64 objUID = -1; if (updateSeabaseMDTable(&cliInterface, catalogNamePart, schemaNamePart, objectNamePart, COM_LIBRARY_OBJECT, "N", tableInfo, 0, NULL, 0, NULL, 0, NULL, objUID)) { deallocEHI(ehi); processReturn(); return; } if (objUID == -1) { deallocEHI(ehi); processReturn(); return; } char * query = new(STMTHEAP) char[1000]; str_sprintf(query, "insert into %s.\"%s\".%s values (%Ld, '%s', %d)", getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_LIBRARIES, objUID, libFileName.data(), createLibraryNode->getVersion()); Lng32 cliRC = cliInterface.executeImmediate(query); NADELETEBASIC(query, STMTHEAP); if (cliRC < 0) { cliInterface.retrieveSQLDiagnostics(CmpCommon::diags()); processReturn(); return; } // hope to remove this call soon by setting thevalid flag to Y sooner if (updateObjectValidDef(&cliInterface, catalogNamePart, schemaNamePart, objectNamePart, COM_LIBRARY_OBJECT_LIT, "Y")) { deallocEHI(ehi); processReturn(); return; } processReturn(); return; }
void CDiagramItem::toXml(QDomElement &n) { QMetaObject *meta = NULL; QMetaProperty prop; QDomDocument doc; QDomElement ext, childNode; QList<QByteArray> props; QStringList filtersOut, filtersIn; CDiagramSerializable *inst = NULL; filtersIn = filterProperties(); filtersOut << "width" << "height" << "x" << "y" << "z" << "pos" << "size" << "parent" << "effect" << "children" << "layout" << "palette"; doc = n.ownerDocument(); ext = doc.createElement( QString("ext") ); childNode = doc.createElement( QString("children") ); n.setAttribute( QString("type"), interType()); n.setAttribute( QString("category"), category() ); n.setAttribute( QString("name"), name() ); n.setAttribute( QString("libCategory"), libraryCategory() ); n.setAttribute( QString("libName"), libraryName() ); n.setAttribute( QString("id"), QString::number(id()) ); meta = const_cast<QMetaObject*>(metaObject()); for (int i = 0; i < meta->propertyCount(); ++i) { QString propName; QByteArray b; QDataStream s(&b, QIODevice::WriteOnly); prop = meta->property(i); propName = QString(prop.name()); if (filtersIn.isEmpty()) { if (filtersOut.contains(propName, Qt::CaseInsensitive) || prop.userType() == 0) { continue; } } else { if (!filtersIn.contains(propName, Qt::CaseInsensitive)) { continue; } } if (prop.isValid() && prop.isReadable()) { s << prop.read(this); QDomElement e = doc.createElement(QString("property")); e.setAttribute( QString("name"), QString(prop.name()) ); e.setAttribute( QString("type"), QString(prop.typeName()) ); e.appendChild( doc.createTextNode( QString(b.toBase64() ) ) ); n.appendChild(e); // qDebug() << "save->name:" << prop.name() << " value:" << prop.read(this); } } props = dynamicPropertyNames(); for (int i = 0; i < props.length(); ++i) { inst = RS_PROPERTY(props.at(i).constData()); // inst = property(props.at(i).constData()).value<CDiagramSerializable*>(); if (inst) { QDomElement c = doc.createElement(QString("child")); c.setAttribute( QString("dynamicProperty"), QString(props.at(i).constData()) ); inst->toXml(c); childNode.appendChild(c); } } n.appendChild(childNode); extToXml( ext ); n.appendChild( ext ); }