Subversion Repositories Kolibri OS

Rev

Rev 855 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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