static void RestoreProfileProps(struct xmlNode *input, PROJECTITEM *root, PROJECTITEM *parent) { struct xmlAttr *attribs = input->attribs; char *type = NULL; char *name = NULL; while (attribs) { if (IsAttrib(attribs, "NAME")) name = attribs->value; else if (IsAttrib(attribs, "TYPE")) type = attribs->value; attribs = attribs->next; } if (type && name) { char *pname = LookupProfileName(name); PROFILE *p = parent->profiles; while (p) { if (p->name == pname) { break; } p = p->next; } if (!p) { PROFILE **q = &parent->profiles; while (*q) q= &(*q)->next; *q = calloc(1, sizeof(PROFILE)); (*q)->name = pname; p = *q; } if (p) { SETTING **s = !stricmp(type,"DEBUG") ? &p->debugSettings : &p->releaseSettings; input = input->children; while (input) { if (IsNode(input, "PROP")) { RestoreOneProp(input, s); } input = input->next; } } } }
void RestoreGeneralProps(struct xmlNode *node, int version) { node = node->children; while (node) { if (IsNode(node, "PROP")) { struct xmlAttr *attribs = node->attribs; char *id = NULL; while (attribs) { if (IsAttrib(attribs, "ID")) id = attribs->value; attribs = attribs->next; } if (id) { SETTING *setting = PropFind(NULL, id); if (!setting) { setting = calloc(1, sizeof(SETTING)); setting->type = e_text; setting->id = strdup(id); InsertSetting(&generalProject, setting); } if (setting) { free(setting->value); setting->value = strdup(node->textData); } } } node = node->next; } }
static void RestoreOneProp(struct xmlNode *input, SETTING **s) { struct xmlAttr *attribs = input->attribs; char *id = NULL; while (attribs) { if (IsAttrib(attribs, "ID")) id = attribs->value; attribs = attribs->next; } if (id) { SETTING *setting = *s; while (setting) { if (!strcmp(setting->id, id)) break; setting = setting->next; } if (!setting) { setting = calloc(1, sizeof(SETTING)); setting->type = e_text; setting->id = strdup(id); setting->next = *s; *s = setting; } if (setting) { free(setting->value); setting->value = strdup(input->textData); } } }
int RestorePreferences(void) { int version; FILE *in; struct xmlNode *root; struct xmlNode *nodes, *children; struct xmlAttr *attribs; char *p; char name[256]; if (!generalProject.profiles) generalProject.profiles = calloc(1, sizeof(PROFILE)); GetUserDataPath(name); strcat(name, PREFFILE); in = fopen(name, "r"); if (!in) { LoadDefaultRules(); return 0; } root = xmlReadFile(in); fclose(in); if (!root || !IsNode(root, "UIPREFS")) { LoadDefaultRules(); return 0; } 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, "PROPERTIES")) RestoreGeneralProps(nodes, version); else if (IsNode(nodes, "MEMWND")) RestoreMemoryWindowSettings(nodes, version); else if (IsNode(nodes, "FIND")) RestoreFindflags(nodes, version); else if (IsNode(nodes, "PLACEMENT")) RestorePlacement(nodes, version); else if (IsNode(nodes, "CUSTOMCOLORS")) RestoreCustomColors(nodes, version); else if (IsNode(nodes, "RULES")) RestoreBuildRules(nodes, version); nodes = nodes->next; } xmlFree(root); PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0); return 1; }
void RestoreMemoryWindowSettings(struct xmlNode *node, int version) { struct xmlAttr *attribs = node->attribs; while (attribs) { if (IsAttrib(attribs, "WORDSIZE")) memoryWordSize = atoi(attribs->value); attribs = attribs->next; } }
void RestoreProps(struct xmlNode *input, PROJECTITEM *root, PROJECTITEM *parent) { while (input) { if (IsNode(input, "PROP")) { // oldformat struct xmlAttr *attribs = input->attribs; char *id = NULL; while (attribs) { if (IsAttrib(attribs, "ID")) id = attribs->value; attribs = attribs->next; } if (strcmp(id, "__DEBUG")) { PROFILE *p = parent->profiles; while (p) { if (!stricmp(p->name, "WIN32")) { break; } p = p->next; } if (!p) { PROFILE **q = &parent->profiles; while (*q) q= &(*q)->next; *q = calloc(1, sizeof(PROFILE)); (*q)->name = sysProfileName; p = *q; } if (p) { RestoreOneProp(input, &p->debugSettings); RestoreOneProp(input, &p->releaseSettings); } } } else if (IsNode(input, "PROFILE")) { RestoreProfileProps(input, root, parent); } input = input->next; } }
static const char *ParseStatusBar(int Type, TCrayon *Crayon, const char *Config) { char *Token=NULL; const char *ptr; TCrayon *StatusBar, *Action; int val; StatusBar=NewCrayonAction(Crayon, Type); StatusBar->Value=10; //parse attribs ptr=GetToken(Config,"\\S",&Token,GETTOKEN_QUOTES); while (ptr) { val=IsAttrib(Token); if (val) StatusBar->Attribs |= val; else { val=IsFlag(Token); if (val==FLAG_REFRESH) { ptr=GetToken(ptr," ",&Token,GETTOKEN_QUOTES); StatusBar->Value=atof(Token); } StatusBar->Flags |= val; } if (! val) break; ptr=GetToken(ptr,"\\S",&Token,GETTOKEN_QUOTES); } //parse selection list and action StatusBar->Match=CopyStr(StatusBar->Match, Token); ptr=GetToken(ptr, "\\S", &StatusBar->String, GETTOKEN_QUOTES); if (strstr(StatusBar->Match, "$m")) MMapSetup(); Action=NewCrayonAction(StatusBar, ACTION_NONE); ptr=ParseAttribs(ptr, StatusBar, &Action); Destroy(Token); return(ptr); }
void RestorePlacement(struct xmlNode *node, int version) { struct xmlAttr *attribs = node->attribs; while (attribs) { if (IsAttrib(attribs, "VALUE")) { WINDOWPLACEMENT wp; wp.length = sizeof(WINDOWPLACEMENT); sscanf(attribs->value, "%d %d %d %d %d %d %d %d %d %d", &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); wp.flags = 0; SetWindowPlacement(hwndFrame, &wp); } attribs = attribs->next; } }
void RestoreFindflags(struct xmlNode *node, int version) { struct xmlAttr *attribs = node->attribs; struct xmlNode *children; while (attribs) { if (IsAttrib(attribs, "FMODE")) findmode = atoi(attribs->value); if (IsAttrib(attribs, "RMODE")) replacemode = atoi(attribs->value); if (IsAttrib(attribs, "FIFFINDMODE")) fiffindmode = atoi(attribs->value); if (IsAttrib(attribs, "FIFREPLACEMODE")) fifreplacemode = atoi(attribs->value); attribs = attribs->next; } children = node->children; while (children) { int index = -1; int fflags = -1; int rflags = -1; attribs = children->attribs; while (attribs) { if (IsAttrib(attribs, "INDEX")) index = atoi(attribs->value); else if (IsAttrib(attribs, "FIND")) index = atoi(attribs->value); else if (IsAttrib(attribs, "REPLACE")) index = atoi(attribs->value); attribs = attribs->next; } if (index != -1 && fflags != -1 && rflags != -1) //FIXME fflags/rflags? { findflags[index] = fflags; replaceflags[index] = rflags; } children = children->next; } }
void RestoreProject(PROJECTITEM *project, BOOL loadWA) { int projectVersion; struct xmlNode *root; struct xmlNode *children; struct xmlAttr *attribs; FILE *in; char name[MAX_PATH]; sprintf(name, "%s.cpj", project->realName); in = fopen(name, "r"); if (!in) { ExtendedMessageBox("Load Error", MB_SETFOREGROUND | MB_SYSTEMMODAL, "Project File %s Not Found",project->displayName); strcat(project->displayName, " (unable to load)"); return; } root = xmlReadFile(in); fclose(in); if (!root || !IsNode(root, "CC386PROJECT")) { LoadErr(root, project->displayName); strcat(project->displayName, " (unable to load)"); return; } if (loadWA) { children = root->children; while (children) { if (IsNode(children, "WORKAREA")) { attribs = children->attribs; while (attribs) { if (IsAttrib(attribs, "NAME")) { LoadWorkArea(attribs->value, TRUE); return; } attribs = attribs->next; } } children = children->next; } } children = root->children; while (children) { if (IsNode(children, "VERSION")) { attribs = children->attribs; while (attribs) { if (IsAttrib(attribs, "ID")) projectVersion = atoi(attribs->value); attribs = attribs->next; } } else if (IsNode(children, "TARGET")) { struct xmlNode *settings = children->children; attribs = children->attribs; while (attribs) { if (IsAttrib(attribs, "TITLE")) { strcpy(project->displayName, attribs->value); } attribs = attribs->next; } while (settings) { if (IsNode(settings, "FILES")) { RestoreFiles(settings->children, project, project); } if (IsNode(settings, "PROPERTIES")) { RestoreProps(settings->children, project, project); } settings = settings->next; } } children = children->next; } xmlFree(root); CalculateProjectDepends(project); project->loaded = TRUE; }
static void RestoreFiles(struct xmlNode *input, PROJECTITEM *root, PROJECTITEM *parent) { while (input) { if (IsNode(input, "FOLDER")) { struct xmlAttr *attribs = input->attribs; PROJECTITEM *folder = calloc(1, sizeof(PROJECTITEM)); if (folder) { PROJECTITEM **ins = &parent->children; while (attribs) { if (IsAttrib(attribs, "TITLE")) { strcpy(folder->displayName, attribs->value); } attribs = attribs->next; } while (*ins && (*ins)->type == PJ_FOLDER && stricmp((*ins)->displayName, folder->displayName) < 0) ins = &(*ins)->next; folder->parent = parent; folder->type = PJ_FOLDER; folder->next = *ins; *ins = folder; RestoreFiles(input->children, root, folder); } } else if (IsNode(input, "FILE")) { struct xmlAttr *attribs = input->attribs; PROJECTITEM *file = calloc(1, sizeof(PROJECTITEM)); if (file) { PROJECTITEM **ins = &parent->children; while (attribs) { if (IsAttrib(attribs, "TITLE")) { strcpy(file->displayName, attribs->value); } else if (IsAttrib(attribs, "NAME")) { strcpy(file->realName, attribs->value); abspath(file->realName, root->realName); } else if (IsAttrib(attribs, "CLEAN")) { file->clean = atoi(attribs->value); } attribs = attribs->next; } while (*ins && (*ins)->type == PJ_FOLDER) ins = &(*ins)->next; while (*ins && stricmp((*ins)->displayName, file->displayName) < 0) ins = &(*ins)->next; file->parent = parent; file->type = PJ_FILE; file->next = *ins; *ins = file; RestorePropsNested(input->children, root, file); } } input = input->next; } }
static const char *ParseAttribs(const char *Verbs, TCrayon *Crayon, TCrayon **Action) { char *Token=NULL; const char *ptr; int val=0; //Do this before anything else! ptr=GetToken(Verbs," ",&Token,0); val=IsAttrib(Token); //Is Attrib actually returns attribs, so if it's >0 we can use it to set //attribs if (val) (*Action)->Attribs |= val; else { val=MatchActionType(Token); switch (val) { case ACTION_CLRTOEOL: (*Action)->Attribs |= FLAG_CLR2EOL; break; case ACTION_RESTORE_XTITLE: *Action=NewCrayonAction(Crayon, ACTION_RESTORE_XTITLE); GlobalFlags |= FLAG_RESTORE_XTITLE; break; case ACTION_REPLACE: case ACTION_SETSTR: case ACTION_SETENV: case ACTION_SEND: case ACTION_PLAYSOUND: case ACTION_EXEC: case ACTION_PASSTO: case ACTION_ECHO: case ACTION_FONT: case ACTION_ARGS: case ACTION_FUNCCALL: case ACTION_XTERM_BGCOLOR: case ACTION_XTERM_FGCOLOR: case ACTION_RXVT_BGCOLOR: case ACTION_RXVT_FGCOLOR: ptr=ParseStringAction(ptr,val,Crayon); break; case ACTION_BGCOLOR: if (strcmp(getenv("TERM"),"rxvt")==0) ptr=ParseStringAction(ptr,ACTION_RXVT_BGCOLOR,Crayon); else ptr=ParseStringAction(ptr,ACTION_XTERM_BGCOLOR,Crayon); break; case ACTION_FGCOLOR: if (strcmp(getenv("TERM"),"rxvt")==0) ptr=ParseStringAction(ptr,ACTION_RXVT_FGCOLOR,Crayon); else ptr=ParseStringAction(ptr,ACTION_XTERM_FGCOLOR,Crayon); break; case ACTION_INFOBAR: case ACTION_QUERYBAR: case ACTION_SELECTBAR: case ACTION_HISTORYBAR: ptr=ParseStatusBar(val, Crayon, ptr); break; default: (*Action)=NewCrayonAction(Crayon, val); break; } } Destroy(Token); return(ptr); }