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

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