source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/Resource.cpp@ 450

Last change on this file since 450 was 402, checked in by dai_9181, 17 years ago

UserProc::SetParamsAndReturnTypeメソッドをリファクタリング
LexicalAnalysis.hのインクルードを除去した

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