static int ReadConfigFile(CurPos &cp) { unsigned char obj; unsigned short len; { const char *p; obj = GetObj(cp, len); assert(obj == CF_STRING); if ((p = GetCharStr(cp, len)) == 0) return -1; if (ConfigSourcePath) free(ConfigSourcePath); ConfigSourcePath = strdup(p); } while ((obj = GetObj(cp, len)) != 0xFF) { switch (obj) { case CF_SUB: { const char *CmdName = GetCharStr(cp, len); if (ReadCommands(cp, CmdName) == -1) return -1; } break; case CF_MENU: { const char *MenuName = GetCharStr(cp, len); if (ReadMenu(cp, MenuName) == -1) return -1; } break; case CF_EVENTMAP: { EEventMap *EventMap = 0; const char *MapName = GetCharStr(cp, len); const char *UpMap = 0; if ((obj = GetObj(cp, len)) != CF_PARENT) return -1; if (len > 0) if ((UpMap = GetCharStr(cp, len)) == 0) return -1; // add new mode if ((EventMap = FindEventMap(MapName)) == 0) { EEventMap *OrgMap = 0; if (strcmp(UpMap, "") != 0) OrgMap = FindEventMap(UpMap); EventMap = new EEventMap(MapName, OrgMap); } else { if (EventMap->Parent == 0) EventMap->Parent = FindEventMap(UpMap); } if (ReadEventMap(cp, EventMap, MapName) == -1) return -1; } break; case CF_COLORIZE: { EColorize *Mode = 0; const char *ModeName = GetCharStr(cp, len); const char *UpMode = 0; if ((obj = GetObj(cp, len)) != CF_PARENT) return -1; if (len > 0) if ((UpMode = GetCharStr(cp, len)) == 0) return -1; // add new mode if ((Mode = FindColorizer(ModeName)) == 0) Mode = new EColorize(ModeName, UpMode); else { if (Mode->Parent == 0) Mode->Parent = FindColorizer(UpMode); } if (ReadColorize(cp, Mode, ModeName) == -1) return -1; } break; case CF_MODE: { EMode *Mode = 0; const char *ModeName = GetCharStr(cp, len); const char *UpMode = 0; if ((obj = GetObj(cp, len)) != CF_PARENT) return -1; if (len > 0) if ((UpMode = GetCharStr(cp, len)) == 0) return -1; // add new mode if ((Mode = FindMode(ModeName)) == 0) { EMode *OrgMode = 0; EEventMap *Map; if (strcmp(UpMode, "") != 0) OrgMode = FindMode(UpMode); Map = FindEventMap(ModeName); if (Map == 0) { EEventMap *OrgMap = 0; if (strcmp(UpMode, "") != 0) OrgMap = FindEventMap(UpMode); Map = new EEventMap(ModeName, OrgMap); } Mode = new EMode(OrgMode, Map, ModeName); Mode->fNext = Modes; Modes = Mode; } else { if (Mode->fParent == 0) Mode->fParent = FindMode(UpMode); } if (ReadMode(cp, Mode, ModeName) == -1) return -1; } break; case CF_OBJECT: { const char *ObjName; if ((ObjName = GetCharStr(cp, len)) == 0) return -1; if (ReadObject(cp, ObjName) == -1) return -1; } break; case CF_EOF: return 0; default: return -1; } } return -1; }
static HWND SearchResource(LPCSTR lpName, int type, DLGPROC pDialogProc, LPARAM param, char *lpFileBase, int TotalFileSize, HWND parentWnd) { char *pResAll = lpFileBase + TotalFileSize; PRES pRes = (PRES)lpFileBase; char pszSearchedName[256]; char *pszType = ResourceType(pRes); char *pszName; int size = ResourceSize(pRes); char Name[512],*bb; PDIALOGBOXHEADER pdbh; HWND result; UINT_PTR ul; ul = (UINT_PTR)lpName; if (HIWORD(ul) == 0) { sprintf(pszSearchedName,"%d",LOWORD(ul)); } else if (IsOrd((char *)lpName)) { sprintf(pszSearchedName,"%d",OrdID(lpName)); } else if (lpName[1] == 0 && lpName[3] == 0) { ConvertWideString((char *)lpName,(char *)pszSearchedName); } else { strcpy(pszSearchedName,lpName); } do { if (pRes->HeaderSize+pRes->DataSize == 0) break; if (IsOrd((char *)pRes) && OrdID(pRes) == ORDID_RT_DLGINCLUDE) { /* Ignore include files */ ; } else if (IsOrd((char *)pRes) && OrdID(pRes) == ORDID_RT_RESOURCE32) { /* * This is the dummy resource that identifies a * 32 bit resource file. This resource should be * skipped also. */ } else { /* This is some other kind of a resource. See if it matches */ if (pRes->DataSize) { int size = ResourceSize(pRes); pszType = ResourceType(pRes); if (IsOrd(pszType) && OrdID(pszType) == type) { pszName = ResourceName(pRes); if (!IsOrd(pszName)) { if (pszName[1] == 0 && pszName[3] == 0) ConvertWideString(pszName,Name); else strcpy(Name,pszName); } else { sprintf(Name,"%d",OrdID(pszName)); } if (!strcmp(Name,pszSearchedName)) { /* found it.*/ if (type == 5) { /* Build a dialog box */ pdbh = (PDIALOGBOXHEADER) SkipResHeader(pRes); bb = malloc(size); memcpy(bb,pdbh,size); result = CreateDialogIndirectParam(GetModuleHandle(NULL), (LPDLGTEMPLATE)bb, parentWnd, pDialogProc,param); free(bb); return result; } else if (type == 4) { /* Build a menu */ return (HWND) ReadMenu((char *)SkipResHeader(pRes)); } else if (type == 3) { /* Build an Icon */ HICON hicon; hicon = CreateIconFromResource((PBYTE)SkipResHeader(pRes), size, TRUE, 0x30000); return (HWND)hicon; } else if (type == 1) { /* Build a cursor */ return (HWND)CreateIconFromResource((PBYTE)SkipResHeader(pRes), size, FALSE, 0x30000); } else if (type == 2 || type == 14) { /* Build bitmap */ char *start = SkipResHeader(pRes); bb = malloc(size); memcpy(bb,start,size); return (HWND) bb; } } } } } /* Move to the next resource. */ pRes = (PRES) (((char *) pRes) + pRes->HeaderSize + pRes->DataSize); DWordAlign((PBYTE *)&pRes); } while (pRes < (PRES) ((char *) pResAll + size)); return (HWND) 0; }