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

📄 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 页
字号:
                    attribs = children->attribs;
                    while (attribs)
                    {
                        if (IsAttrib(attribs, "VALUE"))
                            (*pl)->defineFlags = atoi(attribs->value);
                        attribs = attribs->next;
                    }
                }
                else if (IsNode(children, "FILE"))
                {
                    DEPENDSLIST *dlist = 0,  **dl = &dlist;
                    struct xmlNode *fchildren = children->children;
                    *l = calloc(sizeof(FILELIST), 1);
                    if (! *l)
                        return NoMemory(root, plist);
                    attribs = children->attribs;
                    while (attribs)
                    {
                        if (IsAttrib(attribs, "NAME"))
                        {
                            strcpy((*l)->name, attribs->value);
                            abspath((*l)->name);
                        } 
                        else if (IsAttrib(attribs, "TITLE"))
                        {
                            strcpy((*l)->title, attribs->value);
                        }
                        attribs = attribs->next;
                    }
                    while (fchildren)
                    {
                        if (IsNode(fchildren, "DEPENDENCY"))
                        {
                            *dl = calloc(sizeof(DEPENDSLIST), 1);
                            if (! *dl)
                                return NoMemory(root, plist);

                            attribs = fchildren->attribs;
                            while (attribs)
                            {
                                if (IsAttrib(attribs, "NAME"))
                                {
                                    strcpy((*dl)->name, attribs->value);
                                    abspath((*dl)->name);
                                }
                                else if (IsAttrib(attribs, "TITLE"))
                                {
                                    strcpy((*dl)->title, attribs->value);
                                }
                                attribs = attribs->next;
                            }
                        }
                        dl = &(*dl)->next;
                        fchildren = fchildren->next;
                    }
                    (*l)->depends = dlist;
                    l = &(*l)->next;
                }
                children = children->next;
            }
            (*pl)->files = list;
            pl = &(*pl)->next;
        }
        targets = targets->next;
    }
    xmlFree(root);

    return plist;
}

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

char *nocr(char *s)
{
    static char buf[1024];
    char *p = buf;
    while (*s)
    {
        if (*s != '\r')
            *p++ =  *s;
        s++;
    }
    *p = 0;
    return buf;
}

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

void SaveSettings(FILE *out)
{
    int i;
    fprintf(out, "\t<COLORS KEYWORD=\"%d\" NUMBER=\"%d\" COMMENT=\"%d\"\n"
        "\t\t\tSTRING=\"%d\" ESCAPE=\"%d\" BACKGROUND=\"%d\"\n"
        "\t\t\tTEXT=\"%d\">\n\t\t", keywordColor, numberColor, commentColor,
        stringColor, escapeColor, backgroundColor, textColor);
    for (i = 0; i < 16; i++)
    {
        fprintf(out, "%d ", custColors[i]);
        if (i == 7)
            fprintf(out, "\n\t\t");
    }
    fprintf(out, "\n\t</COLORS>\n");
    fprintf(out, "\t<TABS SPACING=\"%d\"/>\n", tabs);
    fprintf(out, "\t<EDITOR FLAGS=\"%d\"/>\n", editFlags);
}

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

void onehistsave(FILE *out, char **hist, char *name)
{
    int i;
    fprintf(out, "\t<HISTORY TYPE=\"%s\">\n", name);
    for (i = 0; i < MAX_COMBO_HISTORY; i++)
        if (hist[i])
            fprintf(out, "\t\t<HISTITEM VALUE=\"%s\"/>\n", hist[i]);
    fprintf(out, "\t</HISTORY>\n");
}

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

int SaveHistory(FILE *out)
{
    onehistsave(out, findhist1, "FIND1");
    onehistsave(out, findhist2, "FIND2");
    onehistsave(out, replacehist, "REPLACE");
    onehistsave(out, watchhist, "WATCH");
    onehistsave(out, fifhistory, "FINDINFILES");
}

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

void SaveChangeLn(FILE *out)
{
    struct tagfile *list = tagFileList;
    fprintf(out, "\t<CHANGELN>\n");
    while (list)
    {
        if (list->changedLines)
        {
            struct tagchangeln *data = list->changedLines;
            fprintf(out, "\t\t<FILE NAME=\"%s\">\n", relpath(list->name));
            while (data)
            {
                fprintf(out, "\t\t\t<LINE NUM=\"%d\" DELTA=\"%d\"\/>\n", data
                    ->lineno, data->delta);
                data = data->next;
            } fprintf(out, "\t\t</FILE>\n");
        }
        list = list->next;
    }
    fprintf(out, "\t</CHANGELN>\n");
}

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

void saveonetag(FILE *out, int tag)
{
    struct tagfile *list = tagFileList;
    fprintf(out, "\t<TAG ID=\"%d\">\n", tag);
    while (list)
    {
        if (list->tagArray[tag])
        {
            struct tag *data = list->tagArray[tag];
            fprintf(out, "\t\t<FILE NAME=\"%s\">\n", relpath(list->name));
            while (data)
            {
                fprintf(out, 
                    "\t\t\t<TAGITEM LINENO=\"%d\" CP=\"%d\" ENABLED=\"%d\"",
                    data->drawnLineno, data->charpos, data->enabled);

                if (tag == TAG_BOOKMARK)
                    fprintf(out, ">\n%s\n\t\t\t</TAGITEM>\n", xmlConvertString
                        (data->extra, FALSE));
                else
                    fprintf(out, "/>\n");
                data = data->next;
            } fprintf(out, "\t\t</FILE>\n");
        }
        list = list->next;
    }
    fprintf(out, "\t</TAG>\n");
}

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

void SaveTags(FILE *out)
{
    saveonetag(out, TAG_BP);
    saveonetag(out, TAG_BOOKMARK);
}

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

void SaveFont(FILE *out)
{
    int i, j;
    fprintf(out, "\t<FONT>\n\t\t");
    for (i = 0; i < sizeof(LOGFONT); i += 16)
    {
        int k = sizeof(LOGFONT) - i;
        if (k > 16)
            k = 16;
        for (j = 0; j < k; j++)
            fprintf(out, "%d ", *(((unsigned char*) &EditFont) + i + j));
        if (k == 16)
            fprintf(out, "\n\t\t");
    }
    fprintf(out, "\n\t</FONT>\n");
}

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

void SaveDocks(FILE *out)
{
    int i;
    CCW_params p[20];
    CCD_params d[20];
    int len;
    WINDOWPLACEMENT wp;
    GetWindowPlacement(hwndFrame, &wp);
    fprintf(out, "\t<PLACEMENT VALUE=\"%d %d %d %d %d %d %d %d %d %d\"/>\n",
        wp.flags, wp.showCmd, wp.ptMinPosition.x, wp.ptMinPosition.y,
        wp.ptMaxPosition.x, wp.ptMaxPosition.y, wp.rcNormalPosition.left,
        wp.rcNormalPosition.top, wp.rcNormalPosition.right,
        wp.rcNormalPosition.bottom);
    len = dmgrGetInfo(&p[0], &d[0]);
    fprintf(out, "\t<DOCKS>\n");
    for (i = 0; i < len; i++)
    {
        fprintf(out, 
            "\t\t<DOCK ID=\"%d\" VALUE=\"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\"/>\n", p[i].id, d[i].flags, d[i].flexparams, d[i].rowindex, d[i].colindex, d[i].hidden, d[i].hiddenwidth, d[i].oldsize.left, d[i].oldsize.top, d[i].oldsize.right, d[i].oldsize.bottom, d[i].position.left, d[i].position.top, d[i].position.right, d[i].position.bottom, d[i].lastposition.left, d[i].lastposition.top, d[i].lastposition.right, d[i].lastposition.bottom);
    }
    fprintf(out, "\t</DOCKS>\n");
}

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

void SaveWindows(FILE *out)
{
    int i;
    fprintf(out, "\t<EDITWINDOWS>\n");
    for (i = 0; i < numberofdrawwindows; i++)
    {
        POINT p;
        int startpos;
        WINDOWPLACEMENT placement;
        DWINFO *info = (DWINFO*)GetWindowLong(children[i], 0);
        charinfo a;
        SendMessage(GetDlgItem(children[i], ID_EDITCHILD), EM_EXGETSEL, 0, 
            (WPARAM) &a);
        startpos = SendMessage(GetDlgItem(children[i], ID_EDITCHILD),
            EM_EXLINEFROMCHAR, 0, a.min);
        placement.length = sizeof(placement);
        GetWindowPlacement(children[i], &placement);
        p.x = placement.rcNormalPosition.left;
        p.y = placement.rcNormalPosition.top;
        //      ScreenToClient(hwndClient,&p) ;
        fprintf(out, 
            "\t\t<WINDOW NAME=\"%s\" TITLE=\"%s\" X=\"%d\" Y=\"%d\" WIDTH=\"%d\" HEIGHT=\"%d\" LINENO=\"%d\"/>\n", relpath(info->dwName), info->dwTitle, p.x, p.y, placement.rcNormalPosition.right - placement.rcNormalPosition.left, placement.rcNormalPosition.bottom - placement.rcNormalPosition.top, startpos + 1);
    }
    fprintf(out, "\t</EDITWINDOWS>\n");
}

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

void SaveToolBarA(FILE *out, HWND hwnd)
{
    char horiz[512], vert[512];
    int id = GetToolBarData(hwnd, horiz, vert);
    fprintf(out, "\t<TOOLBAR ID=\"%d\" HORIZ=\"%s\" VERT=\"%s\"/>\n", id, horiz,
        vert);
}

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

void SaveToolBars(FILE *out)
{
    SaveToolBarA(out, hwndToolEdit);
    SaveToolBarA(out, hwndToolBuild);
    SaveToolBarA(out, hwndToolDebug);
}

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

void SaveWatchpoints(FILE *out)
{
    int i;
    for (i = 0; i < 4; i++)
    {
        fprintf(out, 
            "\t<WATCH ID=\"%d\" ENABLE=\"%d\" NAME=\"%s\" MODE=\"%d\" SIZE=\"%d\"/>\n", i + 1, !!(hbpEnables &(1 << i)), xmlConvertString(hbpNames[i], TRUE), hbpModes[i], hbpSizes[i]);
    }
}

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

void SaveWorkspace(char *name)
{
    FILE *out;
    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");

    }
    out = fopen(name, "w");
    if (!out)
    {
        ExtendedMessageBox("Save Error", 0, "Could not save workspace");
        return ;
    }
    fprintf(out, "<CCIDEWORKSPACE>\n");
    fprintf(out, "\t<VERSION ID=\"%d\"/>\n", WSPVERS);
    SaveSettings(out);
    SaveFont(out);
    fprintf(out, "\t<BROWSE VALUE=\"%d\"/>\n", browseInfo);
    SaveWatchpoints(out);
    SaveToolBars(out);
    SaveDocks(out);
    SaveWindows(out);
    SaveHistory(out);
    SaveTags(out);
    SaveChangeLn(out);
    fprintf(out, "</CCIDEWORKSPACE>\n");
    fclose(out);
}

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

void ProjectSaveList(int annun)
{
    OPENFILENAME ofn;
    PROJLIST *list = projectList;
    FILE *out;
    if (!projectList)
        return ;
    if (annun && changedProject)
        if (ExtendedMessageBox("Changed Project", MB_YESNO, 
            "Project settings have changed.  Do you wish to save the project?")
            != IDYES)
            return ;
    changedProject = FALSE;
    if (!szProjectTitle[0])
    {
        if (!SaveFileDialog(&ofn, 0, hwndProject, TRUE, szProjectFilter, 
            "ProjDir", "Save Project As"))
            return ;
        strcpy(szProjectName, ofn.lpstrFile);
        out = fopen(ofn.lpstrFile, "w");
    }
    else
        out = fopen(szProjectName, "w");
    if (!out)
    {
        ExtendedMessageBox("Save Error", 0, "Could not save project");
        return ;
    }

    fprintf(out, "<CCIDEPROJECT>\n\t<VERSION ID=\"%d\"/>\n", PROJVERS);
    while (list)
    {
        FILELIST *list1 = list->files;
        DEFINES *d = list->defines;
        char buf[256];
        buf[0] = 0;
        strcpy(buf, relpath(list->outputPath));
        strcpy(buf, xmlConvertString(buf, TRUE));
        fprintf(out, "\t<TARGET NAME=\"%s\" TITLE=\"%s\">\n", relpath(list
            ->name), list->title);
        fprintf(out, "\t\t<BUILD TYPE=\"%d\" FLAGS=\"%d\" LIBTYPE=\"%d\"/>\n",
            list->buildType, list->buildFlags, list->libType);
        fprintf(out, "\t\t<DEBUG FLAGS=\"%x\"/>\n", list->dbgview);
        fprintf(out, "\t\t<PATHS INCLUDE=\"%s\" OUTPUT=\"%s\"/>\n",
            xmlConvertString(relincludepath(list->includePath), TRUE), buf);
        strcpy(buf, xmlConvertString(list->prebuildlabel, TRUE));
        fprintf(out, "\t\t<PREBUILD LABEL=\"%s\">\n\t\t\t%s\n\t\t</PREBUILD>\n",
            buf, xmlConvertString(nocr(list->prebuildsteps), FALSE));
        strcpy(buf, xmlConvertString(list->postbuildlabel, TRUE));
        fprintf(out, 
            "\t\t<POSTBUILD LABEL=\"%s\">\n\t\t\t%s\n\t\t</POSTBUILD>\n", buf,
            xmlConvertString(nocr(list->postbuildsteps), FALSE));
        fprintf(out, "\t\t<OPTS>\n");
        fprintf(out, "\t\t\t<COMPILER>\n\t\t\t\t%s\n\t\t\t</COMPILER>\n",
            xmlConvertString(list->compileopts, FALSE));
        fprintf(out, "\t\t\t<ASSEMBLER>\n\t\t\t\t%s\n\t\t\t</ASSEMBLER>\n",
            xmlConvertString(list->assembleopts, FALSE));
        fprintf(out, "\t\t\t<LINKER>\n\t\t\t\t%s\n\t\t\t</LINKER>\n",
            xmlConvertString(list->linkopts, FALSE));
        fprintf(out, "\t\t\t<LIBRARIAN>\n\t\t\t\t%s\n\t\t\t</LIBRARIAN>\n",
            xmlConvertString(list->libopts, FALSE));
        fprintf(out, "\t\t</OPTS>\n");
        fprintf(out, "\t\t<CMDLINE>\n\t\t\t%s\n\t\t</CMDLINE>\n",
            xmlConvertString(list->cmdline, FALSE));
        fprintf(out, "\t\t<DEFINEFLAGS VALUE=\"%d\"/>\n", list->defineFlags);
        while (d)
        {
            strcpy(buf, xmlConvertString(d->name, TRUE));
            fprintf(out, "\t\t<DEFINE NAME=\"%s\" VALUE=\"%s\"/>\n", buf,
                xmlConvertString(d->value, TRUE));
            d = d->next;
        }
        while (list1)
        {

            fprintf(out, "\t\t<FILE NAME=\"%s\" TITLE=\"%s\"", relpath(list1
                ->name), list1->title);
            if (list1->depends)
            {
                DEPENDSLIST *d = list1->depends;
                fprintf(out, ">\n");
                while (d)
                {
                    fprintf(out, 
                        "\t\t\t<DEPENDENCY NAME=\"%s\" TITLE=\"%s\"/>\n",
                        relpath(d->name), d->title);
                    d = d->next;
                }
                fprintf(out, "\t\t</FILE>\n");
            }
            else
                fprintf(out, "/>\n");
            list1 = list1->next;
        }
        fprintf(out, "\t</TARGET>\n");
        list = list->next;
    }
    fprintf(out, "</CCIDEPROJECT>\n");
    fclose(out);
}

⌨️ 快捷键说明

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