Subversion Repositories Kolibri OS

Rev

Rev 6471 | Rev 7129 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6471 Rev 6502
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
4
;;  Distributed under terms of the GNU General Public License.  ;;
4
;;  Distributed under terms of the GNU General Public License.  ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
8
$Revision: 6471 $
-
 
Line 9... Line 8...
9
 
8
$Revision: 6502 $
10
 
-
 
11
iglobal
-
 
12
; pointer to memory for path replace table,
-
 
13
; size of one record is 128 bytes: 64 bytes for search pattern + 64 bytes for replace string
-
 
14
 
9
 
15
; start with one entry: sys -> 
10
iglobal
16
full_file_name_table dd sysdir_name
-
 
17
.size           dd      1
-
 
18
 
11
full_file_name_table    dd  sysdir_name
Line 19... Line 12...
19
tmp_file_name_size dd   1
12
.size                   dd  1
20
endg
-
 
21
 
13
endg
22
uglobal
14
 
23
; Parser_params will initialize: sysdir_name = "sys", sysdir_path = 
15
uglobal
24
sysdir_name     rb      64
16
sysdir_name     rb  64  ; 'sys',0
25
sysdir_path     rb      64
-
 
26
sysdir_name1    rb      64
-
 
27
sysdir_path1    rb      64
-
 
28
 
-
 
29
; for example:
-
 
30
;dir_name1      db 'KolibriOS',0
-
 
31
;               rb 64-8
-
 
32
;dir_path1      db 'HD0/1',0
-
 
33
;               rb 64-6
-
 
34
endg
-
 
35
 
17
sysdir_path     rb  64
-
 
18
sysdir_name1    rb  64
-
 
19
sysdir_path1    rb  64
-
 
20
endg
-
 
21
; Example:
-
 
22
; align 64
Line 36... Line -...
36
uglobal
-
 
37
tmp_file_name_table dd  ?
23
; sysdir_name1 db 'KolibriOS',0
38
endg
24
; align 64
39
 
25
; sysdir_path1 db 'HD0/1',0
40
; use bx_from_load and init system directory /sys
26
 
41
proc Parser_params
27
proc Parser_params
42
locals
28
    locals
43
  buff db 4 dup(?)              ; for test cd
29
        buff    rb  4   ; for test cd
-
 
30
    endl
-
 
31
        mov     eax, [OS_BASE+0x10000+bx_from_load]
44
endl
32
        mov     ecx, sysdir_path
45
        mov     eax, [OS_BASE+0x10000+bx_from_load]
33
        mov     [ecx-64], dword 'sys'
46
        mov     ecx, sysdir_path
34
        mov     [ecx-2], byte 3
47
        mov     [ecx-64], dword 'sys'
35
        mov     [ecx-1], byte '/'
48
        cmp     al, 'r'; if ram disk
36
        cmp     al, 'r' ; ram disk
49
        jnz     @f
37
        jnz     @f
-
 
38
        mov     [ecx], dword 'RD/?'
50
        mov     [ecx], dword 'RD/?'
39
        mov     [ecx+3], byte ah
51
        mov     [ecx+3], byte ah
40
        mov     [ecx+4], byte 0
52
        mov     [ecx+4], byte 0
41
        ret
53
        ret
42
 
54
@@:
43
@@:
55
        cmp     al, 'm'; if ram disk
44
        cmp     al, 'm'
56
        jnz     @f
45
        jnz     .hard_disk
57
        mov     [ecx], dword 'CD?/'; if cd disk {m}
46
        mov     [ecx], dword 'CD?/'
58
        mov     [ecx+4], byte '1'
47
        mov     [ecx+4], byte '1'
59
        mov     [ecx+5], dword '/KOL'
48
        mov     [ecx+5], dword '/KOL'
60
        mov     [ecx+9], dword 'IBRI'
49
        mov     [ecx+9], dword 'IBRI'
61
        mov     [ecx+13], byte 0
50
        mov     [ecx+13], byte 0
62
.next_cd:
51
.next_cd:
63
        mov     [ecx+2], byte ah
52
        mov     [ecx+2], byte ah
64
        inc     ah
53
        inc     ah
65
        cmp     ah, '5'
54
        cmp     ah, '5'
66
        je      .not_found_cd
55
        je      @f
67
        lea     edx, [buff]
56
        lea     edx, [buff]
68
        pushad
57
        pushad
69
        stdcall read_file, read_firstapp, edx, 0, 4
-
 
70
        popad
-
 
71
        cmp     [edx], dword 'MENU'
58
        stdcall read_file, read_firstapp, edx, 0, 4
-
 
59
        popad
-
 
60
        cmp     [edx], dword 'MENU'
-
 
61
        jne     .next_cd
72
        jne     .next_cd
62
@@:
73
        jmp     .ok
63
        ret
74
 
64
 
75
@@:
65
.hard_disk:
76
        sub     al, 49
66
        sub     al, '1'
77
        mov     [ecx], dword 'HD?/'; if hard disk
67
        mov     [ecx], dword 'HD?/'
78
        mov     [ecx+2], byte al
68
        mov     [ecx+2], byte al
79
        mov     [ecx+4], byte ah
-
 
80
        mov     [ecx+5], dword '/KOL'
-
 
81
        mov     [ecx+9], dword 'IBRI'
-
 
82
        mov     [ecx+13], byte 0
-
 
83
.ok:
-
 
84
.not_found_cd:
-
 
85
        ret
-
 
86
endp
-
 
87
 
-
 
88
proc load_file_parse_table
-
 
89
        stdcall kernel_alloc, 0x1000
-
 
90
        mov     [tmp_file_name_table], eax
-
 
91
        mov     edi, eax
-
 
92
        mov     esi, sysdir_name
-
 
93
        mov     ecx, 128/4
-
 
94
        rep movsd
-
 
95
 
-
 
96
        invoke  ini.enum_keys, conf_fname, conf_path_sect, get_every_key
-
 
97
 
-
 
98
        mov     eax, [tmp_file_name_table]
-
 
99
        mov     [full_file_name_table], eax
-
 
100
        mov     eax, [tmp_file_name_size]
-
 
101
        mov     [full_file_name_table.size], eax
-
 
102
        ret
-
 
103
endp
-
 
104
 
-
 
105
uglobal
-
 
106
def_val_1 db 0
-
 
107
endg
-
 
108
 
-
 
109
proc get_every_key stdcall, f_name, sec_name, key_name
-
 
110
        mov     esi, [key_name]
-
 
111
        mov     ecx, esi
-
 
112
        cmp     byte [esi], '/'
-
 
113
        jnz     @f
-
 
114
        inc     esi
-
 
115
@@:
-
 
116
        mov     edi, [tmp_file_name_size]
-
 
117
        shl     edi, 7
-
 
118
        cmp     edi, 0x1000
-
 
119
        jae     .stop_parse
-
 
120
        add     edi, [tmp_file_name_table]
-
 
121
        lea     ebx, [edi+64]
-
 
122
@@:
-
 
123
        cmp     edi, ebx
-
 
124
        jae     .skip_this_key
-
 
125
        lodsb
-
 
126
        test    al, al
-
 
127
        jz      @f
-
 
128
        or      al, 20h
-
 
129
        stosb
-
 
130
        jmp     @b
-
 
131
@@:
-
 
132
        stosb
-
 
133
 
-
 
134
        invoke  ini.get_str, [f_name], [sec_name], ecx, ebx, 64, def_val_1
-
 
135
 
-
 
136
        cmp     byte [ebx], '/'
-
 
137
        jnz     @f
-
 
138
        lea     esi, [ebx+1]
-
 
139
        mov     edi, ebx
-
 
140
        mov     ecx, 63
-
 
141
        rep movsb
-
 
142
@@:
-
 
143
        push    ebp
-
 
144
        mov     ebp, [tmp_file_name_table]
-
 
145
        mov     ecx, [tmp_file_name_size]
-
 
146
        jecxz   .noreplace
-
 
147
        mov     eax, ecx
-
 
148
        dec     eax
-
 
149
        shl     eax, 7
-
 
150
        add     ebp, eax
-
 
151
.replace_loop:
-
 
152
        mov     edi, ebx
-
 
153
        mov     esi, ebp
-
 
154
@@:
-
 
155
        lodsb
-
 
156
        test    al, al
-
 
157
        jz      .doreplace
-
 
158
        mov     dl, [edi]
-
 
159
        inc     edi
-
 
160
        test    dl, dl
-
 
161
        jz      .replace_loop_cont
-
 
162
        or      dl, 20h
-
 
163
        cmp     al, dl
-
 
164
        jz      @b
-
 
165
        jmp     .replace_loop_cont
-
 
166
.doreplace:
-
 
167
        cmp     byte [edi], 0
-
 
168
        jz      @f
-
 
169
        cmp     byte [edi], '/'
-
 
170
        jnz     .replace_loop_cont
-
 
171
@@:
-
 
172
        lea     esi, [ebp+64]
-
 
173
        call    .replace
-
 
174
        jc      .skip_this_key2
-
 
175
.replace_loop_cont:
-
 
176
        sub     ebp, 128
-
 
177
        loop    .replace_loop
-
 
178
.noreplace:
-
 
179
        pop     ebp
-
 
180
 
-
 
181
        inc     [tmp_file_name_size]
-
 
182
.skip_this_key:
-
 
183
        xor     eax, eax
-
 
184
        inc     eax
-
 
185
        ret
-
 
186
.skip_this_key2:
-
 
187
        pop     ebp
-
 
188
        jmp     .skip_this_key
-
 
189
.stop_parse:
-
 
190
        xor     eax, eax
-
 
191
        ret
-
 
192
endp
-
 
193
 
-
 
194
proc get_every_key.replace
-
 
195
; in: ebx->destination, esi->first part of name, edi->second part of name
-
 
196
; maximum length is 64 bytes
-
 
197
; out: CF=1 <=> overflow
-
 
198
; 1) allocate temporary buffer in stack
-
 
199
        sub     esp, 64
-
 
200
; 2) save second part of name to temporary buffer
-
 
201
        push    esi
-
 
202
        lea     esi, [esp+4]    ; esi->tmp buffer
-
 
203
        xchg    esi, edi        ; edi->tmp buffer, esi->source
-
 
204
@@:
-
 
205
        lodsb
-
 
206
        stosb
-
 
207
        test    al, al
-
 
208
        jnz     @b
-
 
209
; 3) copy first part of name to destination
-
 
210
        pop     esi
-
 
211
        mov     edi, ebx
-
 
212
@@:
-
 
213
        lodsb
-
 
214
        test    al, al
-
 
215
        jz      @f
-
 
216
        stosb
-
 
217
        jmp     @b
-
 
218
@@:
-
 
219
; 4) restore second part of name from temporary buffer to destination
-
 
220
; (may cause overflow)
-
 
221
        lea     edx, [ebx+64]   ; limit of destination
-
 
222
        mov     esi, esp
-
 
223
@@:
-
 
224
        cmp     edi, edx
-
 
225
        jae     .overflow
-
 
226
        lodsb
-
 
227
        stosb
-
 
228
        test    al, al
-
 
229
        jnz     @b
-
 
230
; all is OK
-
 
231
        add     esp, 64         ; CF is cleared
-
 
232
        ret
-
 
233
.overflow:
69
        mov     [ecx+4], byte ah
234
; name is too long
70
        mov     [ecx+5], dword '/KOL'
Line 235... Line 71...
235
        add     esp, 64
71
        mov     [ecx+9], dword 'IBRI'
236
        stc
72
        mov     [ecx+13], byte 0