Exemple #1
0
static rc_t ReportDepend(const ReportFuncs *f,
    uint32_t indent, const VDatabase* db)
{
    rc_t rc = 0;

    const VDBDependencies* dep = NULL;

    const char tag[] = "Dependencies";

    assert(db);

    reportOpen(indent, tag, 0);

    rc = VDatabaseListDependencies(db, &dep, false);
    if (rc != 0) {
        reportError(indent + 1, rc, "VDatabaseListDependencies");
    }
    else {
        uint32_t count = 0;
        rc = VDBDependenciesCount(dep, &count);
        if (rc != 0) { 
            reportError(indent + 1, rc, "VDBDependenciesCount");
        }
        else {
            uint32_t missing = 0;
            const char tag[] = "List";
            rc = VDBDependenciesReportDepend1(dep, f,
                count, indent + 2, false, &missing);

            if (rc == 0) {
                reportOpen(indent + 1, tag, 2, "count", 'd', count,
                    "missing", 'd', missing);
            }
            else {
                reportOpen(indent + 1, tag, 1, "count", 'd', count);
            }
            
            rc = VDBDependenciesReportDepend1(dep, f,
                count, indent + 2, true, &missing);
            reportClose(indent + 1, tag);
        }
    }

    reportClose(indent, tag);

    RELEASE(VDBDependencies, dep);

    return rc;
}
Exemple #2
0
static rc_t CC ReportSOFTWARE(const ReportFuncs *f, uint32_t indent, const char *argv_0, const char *date, ver_t tool_ver ) {
    rc_t rc = 0;

    Report* self = NULL;
    ReportGet(&self);
    assert(self);

    reportOpen(indent, "SOFTWARE", 0);

    if (self->mgr) {
        uint32_t version = 0;
        rc = VDBManagerVersion(self->mgr, &version);
        if (rc != 0) {
            reportOpen(indent + 1, "Library", 0);
            reportError(indent + 2, rc, "VDBManagerVersion");
            reportClose(indent + 1, "Library");
        }
        else { report(indent + 1, "VDBLibrary", 1, "vers", 'V', version); }
    }

    {
        rc_t rc2 = ReportBuild(f, indent + 1, self->mgr);
        if (rc == 0 && rc2 != 0)
        {   rc = rc2; }
    }

    if (argv_0) {
        const char tag[] = "Tool";
        reportOpen(indent + 1, tag, 3, "date", 's', date,
                   "name", 's', argv_0, "vers", 'V', tool_ver);
        {
            rc_t rc2 = ReportBinary(f, indent + 2, argv_0);
            if (rc == 0 && rc2 != 0)
            {   rc = rc2; }
        }
        reportClose(indent + 1, tag);
    }

    reportClose(indent, "SOFTWARE");

    return rc;
}
Exemple #3
0
static
rc_t ReportBuild(const ReportFuncs *f, uint32_t indent, const VDBManager* mgr)
{
    rc_t rc = 0;
    KNamelist* list = NULL;
    reportOpen(indent, "Build", 1, "static", 's', "false");
    if (mgr) {
        rc_t rc2 = VDBManagerListExternalSchemaModules(mgr, &list);
        if (rc2 != 0) {
            reportError
                (indent + 1, rc2, "VDBManagerListExternalSchemaModules");
            if (rc == 0 && rc2 != 0)
            {   rc = rc2; }
        }
        else {
            uint32_t count = 0;
            rc2 = KNamelistCount(list, &count);
            if (rc2 != 0) {
                reportErrorStr(indent + 1, rc2, "KNamelistCount", "origin",
                               "VDBManagerListExternalSchemaModules");
                if (rc == 0 && rc2 != 0)
                {   rc = rc2; }
            }
            else {
                uint32_t i = 0;
                for (i = 0; i < count && rc2 == 0; ++i) {
                    const char* name = NULL;
                    rc2 = KNamelistGet(list, i, &name);
                    if (rc2 != 0) {
                        reportErrorStr(
                            indent + 1, rc2, "KNamelistGet", "origin",
                            "VDBManagerListExternalSchemaModules");
                        if (rc == 0 && rc2 != 0)
                        {   rc = rc2; }
                    }
                    else {
                        report(indent + 1, "Module", 1, "name", 's', name);
                    }
                }
            }
        }
        RELEASE(KNamelist, list);
        reportClose(indent, "Build");
    }
    return rc;
}
int PortListener::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: dataCaptured((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 1: receive(); break;
        case 2: reportWritten((*reinterpret_cast< qint64(*)>(_a[1]))); break;
        case 3: reportClose(); break;
        case 4: reportDsr((*reinterpret_cast< bool(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 5;
    }
    return _id;
}
Exemple #5
0
static
rc_t ReportAlias(const ReportFuncs *f, uint32_t indent, const char* alias, const KDirectory* dir)
{
    char resolved[PATH_MAX + 1];
    rc_t rc
        = KDirectoryResolveAlias(dir, false, resolved, sizeof resolved, "%s", alias);
    if (rc == 0) {
        const char tag[] = "Alias";
        uint32_t type = KDirectoryPathType(dir, "%s", resolved);
        if (type & kptAlias) {
            reportOpen(indent, tag, 1, "resolved", 's', resolved);
            rc = ReportAlias(f, indent + 1, resolved, dir);
            reportClose(indent, tag);
        }
        else
        {   report(indent, tag, 1, "resolved", 's', resolved); }
    }
    return rc;
}
Exemple #6
0
static rc_t ReportBinary(const ReportFuncs *f, uint32_t indent, const char* argv0) {
    rc_t rc = 0;
    KDyld *dyld = NULL;
    assert(argv0);
    rc = KDyldMake(&dyld);
    if (rc != 0) {
        reportError(indent + 1, rc, "KDyldMake");
    }
    else {
        const KDirectory* dir = NULL;
        rc = KDyldHomeDirectory(dyld, &dir, (fptr_t) ReportFinalize);
        if (rc != 0) {
            reportError(indent + 1, rc, "KDyldHomeDirectory");
        }
        else {
            char binary[PATH_MAX + 1];
            const char* name = strpbrk(argv0, "/\\");
            const char* last_name = name;
            if (last_name)
            {   ++last_name; }
            while (name) {
                name = strpbrk(last_name, "/\\");
                if (name) {
                    last_name = name;
                    if (last_name)
                    {   ++last_name; }
                }
            }
            name = last_name ? last_name : argv0;
            rc = KDirectoryResolvePath(dir, true, binary, sizeof binary, "%s", name);
            if (rc != 0) {
                reportErrorStr(indent + 1, rc, "KDirectoryResolvePath",
                    "origin", "KDyldHomeDirectory");
            }
            else {
                bool found = false;
                const char tag[] = "Binary";
                const char* sType = NULL;
                uint8_t digest[16];
                uint32_t type = KDirectoryPathType(dir, "%s", binary);
                switch (type & ~kptAlias) {
                    case kptFile:
                        sType = type & kptAlias ? "alias" : "file";
                        found = true;
                        break;
                    case kptNotFound:
                        sType = "not found";
                        break;
                    default:
                        sType = "unknown";
                        break;
                }
                if (found)
                {   rc = md5(name, digest, dir); }
                if (type & kptAlias) {
                    if (found && rc == 0)  {
                        reportOpen(indent, tag, 3, "path", 's', binary,
                            "type", 's', sType, "md5", 'M', digest);
                    }
                    else {
                        reportOpen(indent, tag, 2, "path", 's', binary,
                            "type", 's', sType);
                    }
                    if (rc == 0 && type & kptAlias)
                    {   rc = ReportAlias(f, indent + 1, name, dir); }
                    reportClose(indent, tag);
                }
                else {
                    if (found && rc == 0)  {
                        report(indent, tag, 3, "path", 's', binary,
                            "type", 's', sType, "md5", 'M', digest);
                    }
                    else {
                        report(indent, tag, 2, "path", 's', binary,
                            "type", 's', sType);
                    }
                }
            }
        }
        RELEASE(KDirectory, dir);
    }
    RELEASE(KDyld, dyld);
    return rc;
}
Exemple #7
0
static rc_t CC ReportObj(const ReportFuncs *f, uint32_t indent,
    const char *object, bool *wasDbOrTableSet)
{
    Report* self = NULL;
    const char* fullpath = NULL;
    const KDatabase* kdb = NULL;
    const KTable* ktbl = NULL;
    const VDatabase* db = NULL;
    KPathType type = kptNotFound;
    KPathType file_type = kptNotFound;
    bool alias = false;
    uint64_t size = 0;
    bool size_unknown = true;

    rc_t rc = ReportGet(&self);
    assert(self);

    if (wasDbOrTableSet != NULL) {
        *wasDbOrTableSet = self->db != NULL || self->table != NULL;
        return 0;
    }

    if (self->db != NULL) {
        type = kptDatabase;
        db = self->db;
    }
    else if (self->table != NULL) {
        rc_t rc2 = VTableOpenParentRead(self->table, &db);
        if (rc2)
        {
            if (rc == 0)
            {
                rc = rc2;
            }
        }
        else if (!db)
        {
            type = kptTable;
            rc2 = VTableGetKTableRead(self->table, &ktbl);
            if (rc2)
            {
                if (rc == 0)
                {
                    rc = rc2;
                }
            }
            else
            {
                rc2 = KTableGetPath(ktbl, &fullpath);
            }
        }
    }

    if (db) {
        rc_t rc2 = VDatabaseOpenKDatabaseRead(db, &kdb);
        type = kptDatabase;
        if (rc2) {
            if (rc == 0)
            {   rc = rc2; }
        }
        else {
            rc2 = KDatabaseGetPath(kdb, &fullpath);
            if (rc2) {
                if (rc == 0)
                {   rc = rc2; }
            }
        }
    }

    if (fullpath) {
        KDirectory* dir = NULL;
        rc_t rc2 = KDirectoryNativeDir(&dir);
        if (rc2) {
            if (rc == 0)
            {   rc = rc2; }
        }
        else {
            file_type = KDirectoryPathType(dir, "%s", fullpath);
            alias = file_type & kptAlias;
            file_type &= ~kptAlias;
            if (file_type == kptFile) {
                rc2 = KDirectoryFileSize(dir, &size, "%s", fullpath);
                if (rc2) {
                    if (rc == 0)
                    {   rc = rc2; }
                }
                else {  size_unknown = false; }
            }
        }
        RELEASE(KDirectory, dir);
    }

    if (object || type != kptNotFound) {
        const char* path
            = fullpath ? fullpath : object ? object : "not set";
        const char* stype = type == kptTable ? "table" : 
            type == kptDatabase ? "database" : "unknown";
        const char* sfile_type = file_type == kptFile ? "archive" : 
            file_type == kptDir ? "dir" : "unexpected";

        if (fullpath && !size_unknown) {
            if (alias)
            { OBJ_P_S_A(indent, path, stype, sfile_type, size); }
            else
            { OBJ_P_S  (indent, path, stype, sfile_type, size); }
        }
        else if (fullpath && size_unknown) {
            if (alias)
            { OBJ_P_A  (indent, path, stype, sfile_type); }
            else
            { OBJ_P    (indent, path, stype, sfile_type); }
        }
        else
        {     OBJ      (indent, path, stype); }

        if (!db)
        {   db = self->db; }

        if (db) {
            rc_t rc2 = ReportDepend(f, indent + 1, db);
            if (rc == 0)
            {   rc = rc2; }
        }
        if (file_type == kptDir) {
            rc_t rc2 = ReportDir(f, indent + 1, ktbl);
            if (rc == 0)
            {   rc = rc2; }
        }

        reportClose(indent, "Object");
    }

    if (db != self->db)
    {   RELEASE(VDatabase, db); }
    RELEASE(KTable, ktbl);
    RELEASE(KDatabase, kdb);

    return rc;
}