Rev 7159 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7113 | GerdtR | 1 | ; ret: |
2 | ; 0 - not found param |
||
3 | ; 1 - found param |
||
4 | ; 2 - error parsing |
||
5 | |||
6 | proc getLastParam ;последний параметр пишет в fInp |
||
7538 | leency | 7 | xor al, al ;to end string |
7113 | GerdtR | 8 | mov edi, params |
9 | mov ecx, 4096 |
||
10 | repne scasb |
||
11 | dec edi |
||
12 | dec edi |
||
13 | test ecx, ecx |
||
14 | jz errorParsing |
||
15 | |||
16 | mov eax, ecx ; - spaces |
||
17 | mov ecx, 4096 |
||
18 | sub ecx, eax |
||
19 | mov al, ' ' |
||
20 | std |
||
21 | repe scasb |
||
22 | cld |
||
23 | inc edi |
||
24 | inc ecx |
||
25 | |||
26 | cmp edi, params |
||
27 | je .noparams |
||
28 | |||
29 | cmp [edi], byte '"' |
||
30 | je .quotation |
||
31 | |||
32 | mov al, ' ' ;find previous space or begin string |
||
33 | std |
||
34 | repne scasb |
||
35 | cld |
||
36 | inc edi |
||
37 | inc edi |
||
38 | |||
39 | mov esi, edi ;copy |
||
40 | mov ebx, edi |
||
41 | mov edi, fInp |
||
42 | |||
43 | xor ecx, ecx |
||
44 | @@:lodsb |
||
45 | cmp al, ' ' |
||
46 | je @f |
||
47 | test al, al |
||
48 | je @f |
||
49 | stosb |
||
50 | inc ecx |
||
51 | jmp @b |
||
52 | @@: |
||
53 | mov [edi], byte 0 |
||
54 | inc edi |
||
55 | |||
56 | mov edi, ebx ;clear |
||
57 | mov al, ' ' |
||
58 | rep stosb |
||
59 | |||
60 | jmp .end |
||
61 | .quotation: |
||
62 | dec edi |
||
63 | mov al, '"' |
||
64 | std |
||
65 | repne scasb |
||
66 | cld |
||
67 | add edi, 2 |
||
68 | cmp [edi-1], byte '"' |
||
69 | jne .err |
||
70 | |||
71 | mov esi, edi |
||
72 | mov ebx, edi |
||
73 | mov edi, fInp |
||
74 | xor ecx, ecx |
||
75 | @@:lodsb |
||
76 | cmp al, '"' |
||
77 | je @f |
||
78 | test al, al |
||
79 | je @f |
||
80 | stosb |
||
81 | inc ecx |
||
82 | jmp @b |
||
83 | @@: |
||
84 | mov [edi], byte 0 |
||
85 | inc edi |
||
86 | |||
87 | mov edi, ebx |
||
88 | dec edi |
||
89 | mov al, ' ' |
||
90 | add ecx, 2 |
||
91 | rep stosb |
||
92 | |||
93 | .end: |
||
94 | mov eax, 1 |
||
95 | ret |
||
96 | .err: |
||
97 | mov eax, 2 |
||
98 | ret |
||
99 | .noparams: |
||
100 | xor eax, eax |
||
101 | endp |
||
102 | |||
7538 | leency | 103 | ;заполняе pathOut |
104 | proc getParamOutPath |
||
7113 | GerdtR | 105 | locals |
106 | retrn rd 0 |
||
107 | endl |
||
108 | mov [retrn], 0 |
||
109 | mov ebx, params |
||
7538 | leency | 110 | |
7113 | GerdtR | 111 | .find_o: |
112 | cmp [ebx], word '-o' |
||
113 | jne .find_o2 |
||
7538 | leency | 114 | |
7113 | GerdtR | 115 | mov edx, ebx |
116 | lea esi, [ebx+3] |
||
7538 | leency | 117 | |
7113 | GerdtR | 118 | @@: ;skiping spaces |
7538 | leency | 119 | cmp esi, params+4096 |
7113 | GerdtR | 120 | jae .errorParsing |
121 | cmp byte[esi], ' ' |
||
122 | jne @f |
||
123 | inc esi |
||
124 | jmp @b |
||
7538 | leency | 125 | @@: |
126 | ;copying ; -o "file" |
||
7113 | GerdtR | 127 | mov ecx, 3 |
128 | cmp byte[esi], '"' |
||
129 | jne ._notspace |
||
130 | inc esi |
||
131 | add ecx, 2 |
||
132 | mov edi, pathOut |
||
133 | mov [retrn], 1 |
||
134 | @@: lodsb |
||
135 | cmp al, '"' |
||
136 | je .clear |
||
137 | stosb |
||
138 | inc ecx |
||
7538 | leency | 139 | cmp esi, params+1024 |
7113 | GerdtR | 140 | jae errorParsing |
141 | jmp @b |
||
142 | |||
143 | ._notspace: ;copying ; -o file |
||
144 | mov edi, pathOut |
||
145 | @@: lodsb |
||
146 | stosb |
||
147 | inc ecx |
||
148 | cmp al, ' ' |
||
149 | je .clear |
||
7538 | leency | 150 | cmp esi, params+1024 |
7113 | GerdtR | 151 | jae errorParsing |
152 | jmp @b |
||
153 | |||
154 | .clear: ;cleaning param |
||
155 | mov [edi], byte 0 |
||
156 | inc edi |
||
157 | mov [retrn], 1 |
||
158 | @@: |
||
159 | mov byte[edx], ' ' |
||
160 | inc edx |
||
161 | loop @b |
||
162 | jmp @f |
||
163 | |||
164 | .find_o2: |
||
165 | inc ebx |
||
7538 | leency | 166 | cmp ebx, params+1024 |
7113 | GerdtR | 167 | jae @f |
168 | cmp byte[ebx], 0 |
||
169 | je @f |
||
170 | jmp .find_o |
||
171 | @@: |
||
172 | |||
173 | |||
174 | |||
175 | mov eax, [retrn] |
||
176 | ret |
||
177 | .errorParsing: |
||
178 | mov eax, 2 |
||
179 | ret |
||
180 | endp |
||
181 | |||
182 | |||
183 | proc getParam key:word |
||
184 | locals |
||
185 | retrn rd 0 |
||
186 | endl |
||
187 | mov [retrn], 0 |
||
188 | mov ebx, params |
||
189 | |||
190 | .find_o: |
||
191 | mov ax, [key] |
||
192 | cmp [ebx], ax |
||
193 | jne .find_o2 |
||
194 | |||
195 | mov edx, ebx |
||
196 | lea esi, [ebx+3] |
||
197 | |||
198 | @@: ;skiping spaces |
||
199 | cmp esi, params+4096 |
||
200 | jae .errorParsing |
||
201 | cmp byte[esi], ' ' |
||
202 | jne @f |
||
203 | inc esi |
||
204 | jmp @b |
||
205 | @@: |
||
206 | |||
7538 | leency | 207 | ;variant1: copying ; -f "file" |
7113 | GerdtR | 208 | mov ecx, 3 |
209 | cmp byte[esi], '"' |
||
210 | jne ._notspace |
||
211 | inc esi |
||
212 | add ecx, 2 |
||
213 | mov edi, [endPointer] |
||
214 | mov [retrn], 1 |
||
215 | @@: lodsb |
||
216 | cmp al, '"' |
||
217 | je .clear |
||
218 | stosb |
||
219 | inc ecx |
||
220 | cmp esi, params+4096 |
||
221 | jae errorParsing |
||
222 | jmp @b |
||
223 | |||
7538 | leency | 224 | ._notspace: ;variant2: copying ; -f file |
7113 | GerdtR | 225 | mov edi, [endPointer] |
226 | @@: lodsb |
||
227 | stosb |
||
228 | inc ecx |
||
229 | cmp al, ' ' |
||
230 | je .clear |
||
231 | cmp esi, params+4096 |
||
232 | jae errorParsing |
||
233 | jmp @b |
||
234 | |||
235 | |||
236 | .clear: ;cleaning param |
||
237 | mov [edi], byte 0 |
||
238 | inc edi |
||
239 | mov [endPointer], edi |
||
240 | mov [retrn], 1 |
||
241 | @@: |
||
242 | mov byte[edx], ' ' |
||
243 | inc edx |
||
244 | loop @b |
||
245 | |||
246 | jmp @f |
||
247 | |||
248 | .find_o2: |
||
249 | inc ebx |
||
250 | cmp ebx, params+4096 |
||
251 | jae @f |
||
252 | cmp byte[ebx], 0 |
||
253 | je @f |
||
254 | jmp .find_o |
||
255 | @@: |
||
256 | |||
257 | |||
258 | |||
259 | mov eax, [retrn] |
||
260 | ret |
||
261 | .errorParsing: |
||
262 | mov eax, 2 |
||
263 | ret |
||
264 | endp |