⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 saveload.c

📁 CC386 is a general-purpose 32-bit C compiler. It is not an optimizing compiler but given that the co
💻 C
📖 第 1 页 / 共 3 页
字号:
    struct tagfile *l,  **ls = &tagFileList;
    struct tag *t,  **ts;
    struct xmlAttr *attribs = node->attribs;
    struct xmlNode *children = node->children;
    int tagid =  - 1;
    while (attribs)
    {
        if (IsAttrib(attribs, "ID"))
            tagid = atoi(attribs->value);
        attribs = attribs->next;
    } if (tagid ==  - 1 || tagid != TAG_BP && tagid != TAG_BOOKMARK)
        return ;
    while (*ls)
        ls = &(*ls)->next;
    while (children)
    {
        if (IsNode(children, "FILE"))
        {
            struct xmlNode *fchildren = children->children;
            *ls = calloc(sizeof(struct tagfile), 1);
            if (!ls)
            {
                NoMemoryWS();
                return ;
            } attribs = children->attribs;
            while (attribs)
            {
                if (IsAttrib(attribs, "NAME"))
                {
                    strcpy((*ls)->name, attribs->value);
                    abspath((*ls)->name);
                }
                attribs = attribs->next;
            }
            l = tagFileList;
            while (l)
            {
                if (!strcmp(l->name, (*ls)->name))
                    break;
                l = l->next;
            }
            if (l !=  *ls)
            {
                free(*ls);
                *ls = 0;
            }
            else
                ls = &(*ls)->next;
            ts = &l->tagArray[tagid];
            while (fchildren)
            {
                if (IsNode(fchildren, "TAGITEM"))
                {
                    *ts = calloc(sizeof(struct tag), 1);
                    if (! *ts)
                    {
                        NoMemoryWS();
                        return ;
                    } attribs = fchildren->attribs;
                    while (attribs)
                    {
                        if (IsAttrib(attribs, "LINENO"))
                            (*ts)->drawnLineno = (*ts)->editingLineno = (*ts)
                                ->debugLineno = atoi(attribs->value);
                        else if (IsAttrib(attribs, "CP"))
                            (*ts)->charpos = atoi(attribs->value);
                        else if (IsAttrib(attribs, "ENABLED"))
                            (*ts)->enabled = atoi(attribs->value);
                        attribs = attribs->next;
                    }
                    if (tagid == TAG_BOOKMARK)
                    {
                        (*ts)->extra = strdup(fchildren->textData);
                    }
                    ts = &(*ts)->next;
                }
                fchildren = fchildren->next;
            }
        }
        children = children->next;
    }
}

//-------------------------------------------------------------------------

void RestoreBrowse(struct xmlNode *node, int version)
{
    struct xmlAttr *attribs = node->attribs;
    while (attribs)
    {
        if (IsAttrib(attribs, "VALUE"))
            browseInfo = atoi(attribs->value);
        attribs = attribs->next;
    } 
}

//-------------------------------------------------------------------------

void RestoreWatch(struct xmlNode *node, int version)
{
    struct xmlAttr *attribs = node->attribs;
    int id = 0;
    while (attribs)
    {
        if (IsAttrib(attribs, "ID"))
        {
            // ID MUST BE FIRST!!!!!
            id = atoi(attribs->value) - 1;
            if (id < 0 || id > 3)
                return ;
        } 
        else if (IsAttrib(attribs, "ENABLE"))
        {
            if (atoi(attribs->value))
                hbpEnables |= (1 << id);
        }
        else if (IsAttrib(attribs, "NAME"))
        {
            strncpy(hbpNames[id], attribs->value, 255);
            hbpNames[id][255] = 0;
        }
        else if (IsAttrib(attribs, "MODE"))
        {
            hbpModes[id] = atoi(attribs->value);
        }
        else if (IsAttrib(attribs, "SIZE"))
        {
            hbpSizes[id] = atoi(attribs->value);
        }
        attribs = attribs->next;
    }
}

//-------------------------------------------------------------------------

void RestoreToolBars(struct xmlNode *node, int version)
{
    int id = 0;
    HWND hwnd;
    char *horiz = 0,  *vert = 0;
    struct xmlAttr *attribs = node->attribs;
    while (attribs)
    {
        if (IsAttrib(attribs, "ID"))
            id = atoi(attribs->value);
        else if (IsAttrib(attribs, "HORIZ"))
            horiz = attribs->value;
        else if (IsAttrib(attribs, "VERT"))
            vert = attribs->value;
        attribs = attribs->next;
    } if (id && horiz && vert)
    {
        switch (id)
        {
            case DID_EDITTOOL:
                hwnd = hwndToolEdit;
                break;
            case DID_BUILDTOOL:
                hwnd = hwndToolBuild;
                break;
            case DID_DEBUGTOOL:
                hwnd = hwndToolDebug;
                break;
            default:
                return ;
        }
        SetToolBarData(hwnd, horiz, vert);
    }
}

//-------------------------------------------------------------------------

void RestoreWorkSpace(char *name, int toerr)
{
    int version;
    FILE *in;
    struct xmlNode *root;
    struct xmlNode *nodes,  *children;
    struct xmlAttr *attribs;
    char buf[256],  *p;
    if (!name)
    {
        if (!projectList)
            return ;
        name = buf;
        strcpy(buf, szProjectName);
        p = strchr(buf, '.');
        if (!p)
            p = buf + strlen(buf);
        strcpy(p, ".cws");

    } in = fopen(name, "r");
    if (!in)
    {
        if (toerr)
            ExtendedMessageBox("Load Error", MB_SETFOREGROUND | MB_SYSTEMMODAL,
                "Workspace File Not Found");
        return ;
    }
    root = xmlReadFile(in);
    fclose(in);
    if (!root || !IsNode(root, "CCIDEWORKSPACE"))
    {
        ExtendedMessageBox("Load Error", 0, "Workspace is invalid file format");
        return ;
    }
    TagEraseAllEntries();
    CloseAll();
    hbpInit();
    nodes = root->children;
    while (nodes)
    {
        if (IsNode(nodes, "VERSION"))
        {
            struct xmlAttr *attribs = nodes->attribs;
            while (attribs)
            {
                if (IsAttrib(attribs, "ID"))
                    version = atoi(attribs->value);
                attribs = attribs->next;
            } 
        }
        else if (IsNode(nodes, "COLORS"))
            RestoreColors(nodes, version);
        else if (IsNode(nodes, "TABS"))
            RestoreTabs(nodes, version);
        else if (IsNode(nodes, "EDITOR"))
            RestoreEditflags(nodes, version);
        else if (IsNode(nodes, "HISTORY"))
            RestoreHistory(nodes, version);
        else if (IsNode(nodes, "FONT"))
            RestoreFont(nodes, version);
        else if (IsNode(nodes, "EDITWINDOWS"))
            RestoreWindows(nodes, version);
        else if (IsNode(nodes, "TAG"))
            RestoreTags(nodes, version);
        else if (IsNode(nodes, "PLACEMENT"))
            RestorePlacement(nodes, version);
        else if (IsNode(nodes, "DOCKS"))
            RestoreDocks(nodes, version);
        else if (IsNode(nodes, "TOOLBAR"))
            RestoreToolBars(nodes, version);
        else if (IsNode(nodes, "BROWSE"))
            RestoreBrowse(nodes, version);
        else if (IsNode(nodes, "WATCH"))
            RestoreWatch(nodes, version);
        else if (IsNode(nodes, "CHANGELN"))
            RestoreChangeLn(nodes, version);
        nodes = nodes->next;
    }
    xmlFree(root);
}

//-------------------------------------------------------------------------

PROJLIST *ProjectLoadList(char *name)
{
    PROJLIST *plist = 0,  **pl = &plist;
    char buf[2049];
    int temp, projectVersion;
    FILE *in = fopen(name, "r");
    struct xmlNode *root;
    struct xmlNode *targets,  *children;
    struct xmlAttr *attribs;
    if (!in)
    {
        ExtendedMessageBox("Load Error", MB_SETFOREGROUND | MB_SYSTEMMODAL, 
            "Project File Not Found");
        return 0;
    } root = xmlReadFile(in);
    fclose(in);
    if (!root || !IsNode(root, "CCIDEPROJECT"))
    {
        return LoadErr(root, name, plist);
    }
    targets = root->children;
    while (targets)
    {
        if (IsNode(targets, "VERSION"))
        {
            attribs = targets->attribs;
            while (attribs)
            {
                if (IsAttrib(attribs, "ID"))
                    projectVersion = atoi(attribs->value);
                attribs = attribs->next;
            }
        }
        else if (IsNode(targets, "TARGET"))
        {
            FILELIST *list = 0,  **l = &list;
            *pl = calloc(sizeof(*plist), 1);
            if (! *pl)
                return NoMemory(root, plist);
            attribs = targets->attribs;
            while (attribs)
            {
                if (IsAttrib(attribs, "NAME"))
                {
                    strcpy((*pl)->name, attribs->value);
                    abspath((*pl)->name);
                }
                else if (IsAttrib(attribs, "TITLE"))
                {
                    strcpy((*pl)->title, attribs->value);
                }
                attribs = attribs->next;
            }
            children = targets->children;
            while (children)
            {
                if (IsNode(children, "BUILD"))
                {
                    attribs = children->attribs;
                    while (attribs)
                    {
                        if (IsAttrib(attribs, "TYPE"))
                            (*pl)->buildType = atoi(attribs->value);
                        else if (IsAttrib(attribs, "FLAGS"))
                            (*pl)->buildFlags = atoi(attribs->value);
                        else if (IsAttrib(attribs, "LIBTYPE"))
                            (*pl)->libType = atoi(attribs->value);
                        attribs = attribs->next;
                    }
                }
                else if (IsNode(children, "DEBUG"))
                {
                    attribs = children->attribs;
                    while (attribs)
                    {
                        if (IsAttrib(attribs, "FLAGS"))
                            (*pl)->dbgview = atoi(attribs->value);
                        attribs = attribs->next;
                    }
                }
                else if (IsNode(children, "PATHS"))
                {
                    attribs = children->attribs;
                    while (attribs)
                    {
                        if (IsAttrib(attribs, "INCLUDE"))
                        {
                            strcpy((*pl)->includePath, attribs->value);
                            abspath((*pl)->includePath);
                        }
                        else if (IsAttrib(attribs, "OUTPUT"))
                        {
                            strcpy((*pl)->outputPath, attribs->value);
                            abspath((*pl)->outputPath);
                        }
                        attribs = attribs->next;
                    }
                }
                else if (IsNode(children, "PREBUILD"))
                {
                    attribs = children->attribs;
                    while (attribs)
                    {
                        if (IsAttrib(attribs, "LABEL"))
                        {
                            strcpy((*pl)->prebuildlabel, attribs->value);
                        }
                        attribs = attribs->next;
                    }
                    if (children->textData)
                    {
                        if (strlen(children->textData) > 1024)
                            return NoMemory(root, plist);
                        strcpy(buf, children->textData);
                        addcr(buf);
                        if (strlen(buf) > 1023)
                            return NoMemory(root, plist);
                        strcpy((*pl)->prebuildsteps, buf);
                    }
                }
                else if (IsNode(children, "POSTBUILD"))
                {
                    attribs = children->attribs;
                    while (attribs)
                    {
                        if (IsAttrib(attribs, "LABEL"))
                        {
                            strcpy((*pl)->postbuildlabel, attribs->value);
                        }
                        attribs = attribs->next;
                    }
                    if (children->textData)
                    {
                        if (strlen(children->textData) > 1024)
                            return NoMemory(root, plist);
                        strcpy(buf, children->textData);
                        addcr(buf);
                        if (strlen(buf) > 1023)
                            return NoMemory(root, plist);
                        strcpy((*pl)->postbuildsteps, buf);
                    }
                }
                else if (IsNode(children, "OPTS"))
                {
                    struct xmlNode *ochildren = children->children;
                    while (ochildren)
                    {
                        if (IsNode(ochildren, "COMPILER"))
                            strcpy((*pl)->compileopts, ochildren->textData);
                        if (IsNode(ochildren, "ASSEMBLER"))
                            strcpy((*pl)->assembleopts, ochildren->textData);
                        if (IsNode(ochildren, "LINKER"))
                            strcpy((*pl)->linkopts, ochildren->textData);
                        if (IsNode(ochildren, "LIBRARIAN"))
                            strcpy((*pl)->libopts, ochildren->textData);
                        ochildren = ochildren->next;
                    } 
                }
                else if (IsNode(children, "CMDLINE"))
                {
                    int len;
                    strcpy((*pl)->cmdline, children->textData);
                }
                else if (IsNode(children, "DEFINE"))
                {
                    DEFINES *d = calloc(sizeof(DEFINES), 1),  **dl = &(*pl)
                        ->defines;
                    if (!d)
                        return NoMemory(root, plist);
                    attribs = children->attribs;
                    while (attribs)
                    {
                        if (IsAttrib(attribs, "NAME"))
                            strcpy(d->name, attribs->value);
                        else if (IsAttrib(attribs, "VALUE"))
                            strcpy(d->value, attribs->value);
                        attribs = attribs->next;
                    }
                    while (*dl)
                        dl = &(*dl)->next;
                    *dl = d;
                }
                else if (IsNode(children, "DEFINEFLAGS"))
                {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -