Subversion Repositories Kolibri OS

Rev

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

Rev 1102 Rev 1234
Line 1... Line 1...
1
;;================================================================================================;;
1
;;================================================================================================;;
2
;;//// libini.asm //// (c) mike.dld, 2006-2008 ///////////////////////////////////////////////////;;
2
;;//// libini.asm ////////////////////////////////////////////////////////////////////////////////;;
-
 
3
;;////  (c) mike.dld, 2006-2008    ///////////////////////////////////////////////////////////////;;
-
 
4
;;////  (c) Vasiliy Kosenko, 2009  ///////////////////////////////////////////////////////////////;;
3
;;================================================================================================;;
5
;;================================================================================================;;
4
;;                                                                                                ;;
6
;;                                                                                                ;;
5
;; This file is part of Common development libraries (Libs-Dev).                                  ;;
7
;; This file is part of Common development libraries (Libs-Dev).                                  ;;
6
;;                                                                                                ;;
8
;;                                                                                                ;;
7
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
9
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
Line 15... Line 17...
15
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev.  ;;
17
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev.  ;;
16
;; If not, see .                                                    ;;
18
;; If not, see .                                                    ;;
17
;;                                                                                                ;;
19
;;                                                                                                ;;
18
;;================================================================================================;;
20
;;================================================================================================;;
19
;;                                                                                                ;;
21
;;                                                                                                ;;
-
 
22
;; 2009-10-25 (vkos)                                                                              ;;
-
 
23
;;   new features:                                                                                ;;
-
 
24
;;     - new function: ini.get_option_str                                                         ;;
20
;; 2009-03-08 (mike.dld)                                                                          ;;
25
;; 2009-03-08 (mike.dld)                                                                          ;;
21
;;   bug-fixes:                                                                                   ;;
26
;;   bug-fixes:                                                                                   ;;
22
;;     - moved buffer bound check in libini._.low.read_value up (reported by Insolor)             ;;
27
;;     - moved buffer bound check in libini._.low.read_value up (reported by Insolor)             ;;
23
;;   new features:                                                                                ;;
28
;;   new features:                                                                                ;;
24
;;     - comments support (char is ini.COMMENT_CHAR, defaults to ';')                             ;;
29
;;     - comments support (char is ini.COMMENT_CHAR, defaults to ';')                             ;;
Line 70... Line 75...
70
 
75
 
Line 71... Line 76...
71
section '.flat' code readable align 16
76
section '.flat' code readable align 16
Line -... Line 77...
-
 
77
 
-
 
78
include 'libini_p.asm'
-
 
79
 
-
 
80
;; For ini.get_option_str
72
 
81
str_find_in_array fix libini._.find_string
73
include 'libini_p.asm'
82
include 'find_str.asm'
74
 
83
 
75
;;================================================================================================;;
84
;;================================================================================================;;
76
proc ini.enum_sections _f_name, _callback ;///////////////////////////////////////////////////////;;
85
proc ini.enum_sections _f_name, _callback ;///////////////////////////////////////////////////////;;
Line 655... Line 664...
655
 
664
 
656
	pop	edi edx ecx
665
	pop	edi edx ecx
657
	ret
666
	ret
Line -... Line 667...
-
 
667
endp
-
 
668
 
-
 
669
;;================================================================================================;;
-
 
670
proc ini.get_option_str _f_name, _sec_name, _key_name, _option_list, _length, _def_val ;//////////;;
-
 
671
;;------------------------------------------------------------------------------------------------;;
-
 
672
;? Read string, compare with list of possible & return its' number                                ;;
-
 
673
;;------------------------------------------------------------------------------------------------;;
-
 
674
;> _f_name = ini filename                                                                 ;;
-
 
675
;> _sec_name = section name                                                               ;;
-
 
676
;> _key_name = key name                                                                   ;;
-
 
677
;> _option_list = list of options               ;;
-
 
678
;> _length = maximum length of string                                                             ;;
-
 
679
;> _def_val = default value to return if no key, section or file found                     ;;
-
 
680
;;------------------------------------------------------------------------------------------------;;
-
 
681
;< eax = [_def_val] (error) / number of option string in _option_list                      ;;
-
 
682
;;================================================================================================;;
-
 
683
locals
-
 
684
  buff rb ini.MAX_VALUE_LEN
-
 
685
endl
-
 
686
	
-
 
687
	lea eax, [buff]
-
 
688
	stdcall ini.get_str, [_f_name], [_sec_name], [_key_name], eax, ini.MAX_VALUE_LEN
-
 
689
	
-
 
690
	inc eax
-
 
691
	test eax, eax
-
 
692
	je .default
-
 
693
	
-
 
694
	;; Now convert option from string to number
-
 
695
	lea eax, [buff]
-
 
696
	sub esp, 4
-
 
697
	stdcall libini._.find_string, [_option_list], eax
-
 
698
	add esp, 4
-
 
699
	
-
 
700
	inc eax
-
 
701
	test eax, eax
-
 
702
	je .default
-
 
703
	dec eax
-
 
704
	
-
 
705
.default:
-
 
706
	mov eax, dword [_def_val]
-
 
707
	
-
 
708
.exit:
-
 
709
; 	leave
Line 658... Line 710...
658
endp
710
	ret
659
 
711
endp
660
 
712
 
661
;;================================================================================================;;
713
;;================================================================================================;;
Line 695... Line 747...
695
 
747
 
696
 
748
 
Line 697... Line -...
697
align 16
-
 
698
@EXPORT:
749
align 16
699
 
750
@EXPORT:
700
export						  \
751
 
701
	libini._.init	  , 'lib_init'		, \
752
export	libini._.init	  , 'lib_init'		, \
702
	0x00080008	  , 'version'		, \
753
	0x00080008	  , 'version'		, \
703
	ini.enum_sections , 'ini_enum_sections' , \
754
	ini.enum_sections , 'ini_enum_sections' , \
704
	ini.enum_keys	  , 'ini_enum_keys'	, \
755
	ini.enum_keys	  , 'ini_enum_keys'	, \
705
	ini.get_str	  , 'ini_get_str'	, \
756
	ini.get_str	  , 'ini_get_str'	, \
706
	ini.get_int	  , 'ini_get_int'	, \
757
	ini.get_int	  , 'ini_get_int'	, \
707
	ini.get_color	  , 'ini_get_color'	, \
758
	ini.get_color	  , 'ini_get_color'	, \
-
 
759
	ini.set_str	  , 'ini_set_str'	, \