source: dev/trunk/abdev/BasicCompiler_Common/Resource.cpp@ 279

Last change on this file since 279 was 206, checked in by dai_9181, 17 years ago

コード全体のリファクタリングを実施

File size: 3.5 KB
Line 
1#include "stdafx.h"
2
3#include <jenga/include/smoothie/LexicalAnalysis.h>
4
5#include <Type.h>
6
7#include "common.h"
8
9void GetResourceData(char *FileName){
10 extern HANDLE hHeap;
11 extern char BasicCurDir[MAX_PATH];
12 int i2,i3;
13 char *buffer,temporary[MAX_PATH],temp2[MAX_PATH];
14 HANDLE hFile;
15 DWORD dwId;
16
17 extern RESOURCEDATAINFO *pCursorResourceInfo;
18 extern int CursorResourceNum;
19 extern RESOURCEDATAINFO *pBitmapResourceInfo;
20 extern int BitmapResourceNum;
21 extern RESOURCEDATAINFO *pIconResourceInfo;
22 extern int IconResourceNum;
23 pCursorResourceInfo=(RESOURCEDATAINFO *)HeapAlloc(hHeap,0,1);
24 CursorResourceNum=0;
25 pBitmapResourceInfo=(RESOURCEDATAINFO *)HeapAlloc(hHeap,0,1);
26 BitmapResourceNum=0;
27 pIconResourceInfo=(RESOURCEDATAINFO *)HeapAlloc(hHeap,0,1);
28 IconResourceNum=0;
29
30 extern char szManifestPath[MAX_PATH];
31 extern int XPManiResourceNum;
32 szManifestPath[0]=0;
33 XPManiResourceNum=0;
34
35 hFile=CreateFile(FileName,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
36 if(hFile==INVALID_HANDLE_VALUE) return;
37 i2=GetFileSize(hFile,NULL);
38 buffer=(char *)HeapAlloc(hHeap,0,i2+i2);
39 ReadFile(hFile,buffer,i2,(DWORD *)&i3,NULL);
40 CloseHandle(hFile);
41 buffer[i3]=0;
42 ChangeReturnCode(buffer);
43
44 i2=0;
45 while(1){
46 //ID
47 while(buffer[i2]==' '||buffer[i2]=='\t') i2++;
48 for(i3=0;;i2++,i3++){
49 if(!IsVariableChar(buffer[i2])){
50 temporary[i3]=0;
51 break;
52 }
53 temporary[i3]=buffer[i2];
54 }
55 if(temporary[0]=='\0') break;
56
57 _int64 i64data;
58 Type resultType;
59 if( !StaticCalculation(true, temporary,0,&i64data,resultType) ){
60 return;
61 }
62 if(resultType.IsReal()){
63 SetError(9,temporary,0);
64 return;
65 }
66 dwId=(DWORD)i64data;
67
68 //Type
69 while(buffer[i2]==' '||buffer[i2]=='\t') i2++;
70 for(i3=0;;i2++,i3++){
71 if(!IsVariableChar(buffer[i2])){
72 temporary[i3]=0;
73 break;
74 }
75 temporary[i3]=buffer[i2];
76 }
77
78 //FileName
79 while(buffer[i2]==' '||buffer[i2]=='\t') i2++;
80 if(buffer[i2]!='\"'){
81 //エラー
82 return;
83 }
84 for(i2++,i3=0;;i2++,i3++){
85 if(buffer[i2]=='\"'){
86 temp2[i3]=0;
87 break;
88 }
89 temp2[i3]=buffer[i2];
90 }
91 GetFullPath(temp2,BasicCurDir);
92
93 if(lstrcmpi(temporary,"CURSOR")==0){
94 pCursorResourceInfo=(RESOURCEDATAINFO *)HeapReAlloc(hHeap,0,pCursorResourceInfo,(CursorResourceNum+1)*sizeof(RESOURCEDATAINFO));
95 pCursorResourceInfo[CursorResourceNum].dwId=dwId;
96 lstrcpy(pCursorResourceInfo[CursorResourceNum].FileName,temp2);
97 CursorResourceNum++;
98 }
99 else if(lstrcmpi(temporary,"BITMAP")==0){
100 pBitmapResourceInfo=(RESOURCEDATAINFO *)HeapReAlloc(hHeap,0,pBitmapResourceInfo,(BitmapResourceNum+1)*sizeof(RESOURCEDATAINFO));
101 pBitmapResourceInfo[BitmapResourceNum].dwId=dwId;
102 lstrcpy(pBitmapResourceInfo[BitmapResourceNum].FileName,temp2);
103 BitmapResourceNum++;
104 }
105 else if(lstrcmpi(temporary,"ICON")==0){
106 pIconResourceInfo=(RESOURCEDATAINFO *)HeapReAlloc(hHeap,0,pIconResourceInfo,(IconResourceNum+1)*sizeof(RESOURCEDATAINFO));
107 pIconResourceInfo[IconResourceNum].dwId=dwId;
108 lstrcpy(pIconResourceInfo[IconResourceNum].FileName,temp2);
109 IconResourceNum++;
110 }
111 else if(lstrcmpi(temporary,"RT_MANIFEST")==0){
112 if(XPManiResourceNum) goto error;
113
114 lstrcpy(szManifestPath,temp2);
115
116 XPManiResourceNum++;
117 }
118 else{
119error:
120 SetError(17,NULL,0);
121 return;
122 }
123
124 i2++;
125 while(buffer[i2]==' '||buffer[i2]=='\t') i2++;
126 if(buffer[i2]=='\0') break;
127 else if(buffer[i2]!='\n'){
128 SetError(17,NULL,0);
129 return;
130 }
131 i2++;
132 }
133
134 HeapDefaultFree(buffer);
135}
Note: See TracBrowser for help on using the repository browser.