Esempio n. 1
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;
}
Esempio n. 2
0
static rc_t ShowModules(const KConfig* cfg, const Params* prm) {
    rc_t rc = 0;
#ifdef _STATIC
    OUTMSG(("<!-- Modules are not used in static build -->\n"));
#else
    const VDBManager* mgr = NULL;
    KNamelist* list = NULL;
    OUTMSG(("<!-- Modules -->\n"));
    rc = VDBManagerMakeRead(&mgr, NULL);
    DISP_RC(rc, "while calling VDBManagerMakeRead");
    if (rc == 0) {
        rc = VDBManagerListExternalSchemaModules(mgr, &list);
        DISP_RC(rc, "while calling VDBManagerListExternalSchemaModules");
    }
    if (rc == 0) {
        uint32_t count = 0;
        rc = KNamelistCount(list, &count);
        DISP_RC(rc, "while calling KNamelistCount "
            "on VDBManagerListExternalSchemaModules result");
        if (rc == 0) {
            int64_t i = 0;
            for (i = 0; i < count && rc == 0; ++i) {
                const char* name = NULL;
                rc = KNamelistGet(list, i, &name);
                DISP_RC(rc, "while calling KNamelistGet "
                    "on VDBManagerListExternalSchemaModules result");
                if (rc == 0) {
                    OUTMSG(("%s\n", name));
                }
            }
        }
    }
    OUTMSG(("\n"));
    RELEASE(KNamelist, list);
    RELEASE(VDBManager, mgr);
#endif
#if 0
    KDirectory* dir = NULL;
    const char* paths[] = { "vdb/module/paths", "vdb/wmodule/paths" };
    int i = 0;
    assert(cfg);
    for (i = 0; i < sizeof paths / sizeof paths[0] && rc == 0; ++i) {
        const KConfigNode* node = NULL;
        if (rc == 0) {
            const char* path = paths[i];
            rc = KConfigOpenNodeRead(cfg, &node, path);
            if (rc != 0) {
                if (GetRCState(rc) == rcNotFound) {
                    rc = 0;
                    continue;
                }
                else {  DISP_RC(rc, path); }
            }
            else {
                char buf[PATH_MAX + 1];
                size_t num_read = 0;
                size_t remaining = 0;
                rc = KConfigNodeRead(node, 0,
                    buf, sizeof buf, &num_read, &remaining);
                assert(remaining == 0);
                assert(num_read <= sizeof buf);
                DISP_RC(rc, path);
                if (rc == 0) {
                    if (num_read < sizeof buf) {
                        buf[num_read] = '\0';
                        if (dir == NULL)
                        {   rc = KDirectoryNativeDir(&dir); }
                        if (rc == 0) {
                            OUTMSG(("%s = %s\n", path, buf));
                            rc = ShowModDir(dir, buf);
                            if (rc == 0)
                            {   OUTMSG(("\n")); }
                        }
                    }
                }
            }
            RELEASE(KConfigNode, node);
        }
    }
    RELEASE(KDirectory, dir);
#endif
    return rc;
}