Rev 109 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | ;workarea: <- RTF_work |
2 | ; listptr dd savelist 0 |
||
3 | ; szKeyword rb 31 4 |
||
4 | ; szParameter rb 21 35 |
||
5 | |||
6 | include 'rtftype.inc' |
||
7 | include 'rtfactn.inc' |
||
8 | |||
9 | read_next_block: |
||
10 | inc [cur_block] |
||
11 | read_block: |
||
12 | mov esi,I_END |
||
13 | pusha |
||
14 | mov ecx,[cur_block] |
||
15 | mov ebx,fileinfo |
||
16 | mov eax,ecx |
||
139 | diamond | 17 | shl eax,16 |
31 | halyavin | 18 | mov [ebx+4],eax |
19 | ; mov [ebx+12],esi |
||
139 | diamond | 20 | mcall 70 |
31 | halyavin | 21 | if DEBUG_BLOCK eq 1 |
22 | ; dps 'B=' |
||
23 | ; dpd ecx |
||
24 | ; dps <13,10> |
||
25 | end if |
||
26 | cmp ecx,[max_block] |
||
27 | je .last |
||
28 | mov ebx,I_END+RTFSIZE |
||
29 | jmp .add |
||
30 | .last: |
||
31 | mov ebx,[tail] |
||
32 | ; dpd ebx |
||
33 | .add: |
||
34 | ; dpd ebx |
||
35 | mov [block_end],ebx |
||
36 | popa |
||
37 | ; dpd esi |
||
38 | ; dps <13,10> |
||
39 | ret |
||
40 | ; |
||
41 | ; %%Function: ecRtfParse |
||
42 | ; |
||
43 | ; Step 1: |
||
44 | ; Isolate RTF keywords and send them to ecParseRtfKeyword; |
||
45 | ; Push and pop state at the start and end of RTF groups; |
||
46 | ; Send text to ecParseChar for further processing. |
||
47 | ; |
||
48 | macro CopySave _src,_dest |
||
49 | { |
||
50 | pusha |
||
51 | mov ecx,SIZE_save |
||
52 | mov esi,_src |
||
53 | mov edi,_dest |
||
54 | rep movsb |
||
55 | popa |
||
56 | } |
||
57 | |||
58 | RtfParse: |
||
59 | |||
60 | if BENCH eq 1 |
||
61 | mcall 26,9 |
||
62 | mov [bench],eax |
||
63 | end if |
||
64 | mov [RetroPtr],esi |
||
65 | CopySave Chp,RetroSave |
||
66 | push dword[Free+4] |
||
67 | pop dword[RetroXY] |
||
68 | xor eax,eax |
||
69 | mov [cur_block],eax |
||
70 | mov [RetroBlock],eax |
||
71 | push [cGroup] |
||
72 | pop [RetroGroup] |
||
73 | and [mode],not RTF_BLIND |
||
74 | mov [listptr],save_stack |
||
139 | diamond | 75 | mov [fileinfo.size],128*512 |
31 | halyavin | 76 | ; test ebp,RTF_HELP |
77 | test [mode],RTF_HELP |
||
78 | jne .noread |
||
79 | call read_block |
||
80 | .noread: |
||
81 | mov [RetroPtr],esi |
||
82 | .nib2: |
||
83 | mov [nibble],2 |
||
84 | and [b],al |
||
85 | .getc: |
||
86 | xor eax,eax |
||
87 | lods_block |
||
88 | cmp [cGroup],0 |
||
89 | jge .ok1 |
||
90 | Return ecStackUnderflow |
||
91 | .ok1: |
||
92 | cmp [ris],risBin |
||
93 | jne .nobin |
||
94 | RetError ecParseChar |
||
95 | .nobin: |
||
96 | cmp al,'{' |
||
97 | jne .nobr1 |
||
98 | RetError ecPushRtfState |
||
99 | .nobr1: |
||
100 | cmp al,'}' |
||
101 | jne .nobr2 |
||
102 | RetError ecPopRtfState |
||
103 | .nobr2: |
||
104 | cmp al,'\' |
||
105 | jne .noslash |
||
106 | RetError ecParseRtfKeyword |
||
107 | .noslash: |
||
108 | cmp al,0xd |
||
109 | je .getc |
||
110 | cmp al,0xa |
||
111 | je .getc |
||
112 | .nouc: |
||
113 | cmp [ris],risNorm |
||
114 | jne .nonorm |
||
115 | call ecParseChar |
||
116 | cmp eax,ecOutOfWindow |
||
117 | je .__ex |
||
118 | test eax,eax |
||
119 | je .getc |
||
120 | jmp .__ex |
||
121 | .nonorm: |
||
122 | cmp [ris],risHex |
||
123 | je .noassert |
||
124 | Return ecAssertion |
||
125 | .noassert: |
||
126 | shl [b],4 |
||
127 | isdigit al, .nodig |
||
128 | sub al,'0' |
||
129 | add [b],al |
||
130 | jmp .nibble |
||
131 | .nodig: |
||
132 | islower al, .nolow |
||
133 | cmp al,'a' |
||
134 | jb .inval |
||
135 | cmp al,'f' |
||
136 | ja .inval |
||
137 | sub al,'a'-10 |
||
138 | jmp .nib0 |
||
139 | .inval: |
||
140 | if INVALHEX eq 0 |
||
141 | jmp .getc |
||
142 | else |
||
143 | ; sub esi,I_END+1 |
||
144 | ; dpd esi |
||
145 | ; movzx eax,al |
||
146 | ; dpd eax |
||
147 | ; movzx eax,[b] |
||
148 | ; dpd eax |
||
149 | Return ecInvalidHex |
||
150 | end if |
||
151 | .nolow: |
||
152 | cmp al,'A' |
||
153 | jb .inval |
||
154 | cmp al,'F' |
||
155 | ja .inval |
||
156 | sub al,'A'-10 |
||
157 | .nib0: |
||
158 | add [b],al |
||
159 | .nibble: |
||
160 | dec [nibble] |
||
161 | cmp [nibble],0 |
||
162 | jnz .getc |
||
163 | movzx eax,[b] |
||
164 | mov [ris],risNorm |
||
165 | call ecParseChar |
||
166 | test eax,eax |
||
167 | jnz .__ex |
||
168 | ; mov [ris],risNorm |
||
169 | jmp .nib2 |
||
170 | .eof: |
||
171 | xor eax,eax |
||
172 | cmp eax,[cGroup] |
||
173 | je .__ex |
||
174 | jg .unbr |
||
175 | Return ecStackUnderflow |
||
176 | .unbr: |
||
177 | mov eax,ecUnmatchedBrace |
||
178 | .__ex: |
||
179 | ret |
||
180 | nibble db 2 |
||
181 | b db 0 |
||
182 | RTF_maxlist dd ? |
||
183 | ; |
||
184 | ; %%Function: ecParseRtfKeyword |
||
185 | ; |
||
186 | ; Step 2: |
||
187 | ; get a control word (and its associated value) and |
||
188 | ; call ecTranslateKeyword to dispatch the control. |
||
189 | ; |
||
190 | |||
191 | ecParseRtfKeyword: |
||
192 | ; ch-al,bl-fParam, bh-fNeg |
||
193 | mov [ris],risNorm |
||
194 | xor eax,eax |
||
195 | xor ebx,ebx |
||
196 | push edx |
||
197 | mov [szKeyword],al |
||
198 | mov [szParameter],al |
||
199 | lods_block |
||
200 | isalpha al,.ctrl |
||
201 | jmp .alph |
||
202 | .ctrl: |
||
203 | push esi |
||
204 | mov esi,szKeyword |
||
205 | inc byte[esi] |
||
206 | mov [esi+1],al |
||
207 | mov eax,ebx |
||
208 | xor ebx,ebx |
||
209 | call ecTranslateKeyword |
||
210 | pop esi |
||
211 | jmp .__ex |
||
212 | .alph: |
||
213 | push edi |
||
214 | mov edi,szKeyword+1 |
||
215 | .loop1: |
||
216 | stosb |
||
217 | inc [szKeyword] |
||
218 | lods_block |
||
219 | isalpha al,.outloop1 |
||
220 | jmp .loop1 |
||
221 | .outloop1: |
||
222 | pop edi |
||
223 | cmp al,'-' |
||
224 | jne .noneg |
||
225 | not bh |
||
226 | lods_block |
||
227 | .noneg: |
||
228 | isdigit al,.nodig |
||
229 | not bl |
||
230 | push edi |
||
231 | mov edi,szParameter+1 |
||
232 | .loop2: |
||
233 | stosb |
||
234 | inc [szParameter] |
||
235 | lods_block |
||
236 | isdigit al,.outloop2 |
||
237 | jmp .loop2 |
||
238 | .outloop2: |
||
239 | pop edi |
||
240 | push eax esi |
||
241 | mov esi,szParameter |
||
242 | atoi |
||
243 | pop esi |
||
244 | mov edx,eax |
||
245 | pop eax |
||
246 | mov [lParam],edx |
||
247 | test bh,bh |
||
248 | jz .nodig |
||
249 | neg edx |
||
250 | .nodig: |
||
251 | cmp al,' ' |
||
252 | je .space |
||
253 | cmp esi,I_END |
||
254 | jne .ok_block |
||
255 | dec [cur_block] |
||
256 | call read_block |
||
257 | mov esi,[block_end] |
||
258 | .ok_block: |
||
259 | dec esi |
||
260 | .space: |
||
261 | mov eax,ebx |
||
262 | mov ebx,edx |
||
263 | push esi |
||
264 | mov esi,szKeyword |
||
265 | call ecTranslateKeyword |
||
266 | pop esi |
||
267 | .__ex: |
||
268 | pop edx |
||
269 | ret |
||
270 | |||
271 | ; |
||
272 | ; %%Function: ecParseChar |
||
273 | ; |
||
274 | ; Route the character to the appropriate destination stream. |
||
275 | ; |
||
276 | |||
277 | ecParseChar: |
||
278 | ;in: ch-al, esi->rtf |
||
279 | cmp [ris],risBin |
||
280 | jne .nobin |
||
281 | dec [cbBin] |