Added function ini_get_bool

git-svn-id: svn://kolibrios.org@1240 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
vkos 2009-10-27 10:49:19 +00:00
parent fbe5f5e77e
commit 6e1bd03300
2 changed files with 42 additions and 4 deletions

View File

@ -19,6 +19,9 @@
;; ;; ;; ;;
;;================================================================================================;; ;;================================================================================================;;
;; ;; ;; ;;
;; 2009-10-27 (vkos) ;;
;; new features: ;;
;; - new function: ini.get_bool ;;
;; 2009-10-25 (vkos) ;; ;; 2009-10-25 (vkos) ;;
;; new features: ;; ;; new features: ;;
;; - new function: ini.get_option_str ;; ;; - new function: ini.get_option_str ;;
@ -676,7 +679,7 @@ proc ini.get_option_str _f_name, _sec_name, _key_name, _option_list, _length, _d
;> _key_name = key name <asciiz> ;; ;> _key_name = key name <asciiz> ;;
;> _option_list = list of options <pointer to zero-ended archive of asciiz-pointers> ;; ;> _option_list = list of options <pointer to zero-ended archive of asciiz-pointers> ;;
;> _length = maximum length of string ;; ;> _length = maximum length of string ;;
;> _def_val = default value to return if no key, section or file found <dword> ;; ;> _def_val = default value to return if no key, section, file found or incorrect string <dword> ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;< eax = [_def_val] (error) / number of option string in _option_list <dword> ;; ;< eax = [_def_val] (error) / number of option string in _option_list <dword> ;;
;;================================================================================================;; ;;================================================================================================;;
@ -707,7 +710,40 @@ endl
mov eax, dword [_def_val] mov eax, dword [_def_val]
.exit: .exit:
; leave ret
endp
;; Note that order of following array should be: false-true-false-true-...-0
_bool_strings_list:
dd _bool_no
dd _bool_yes
dd _bool_disabled
dd _bool_enabled
dd _bool_false
dd _bool_true
dd 0
_bool_no: db "no", 0
_bool_false: db "false", 0
_bool_disabled: db "disabled", 0
_bool_yes: db "yes", 0
_bool_true: db "true", 0
_bool_enabled: db "enabled", 0
;;================================================================================================;;
proc ini.get_bool _f_name, _sec_name, _key_name, _def_val ;///////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;;
;? Read boolean value ;;
;;------------------------------------------------------------------------------------------------;;
;> _f_name = ini filename <asciiz> ;;
;> _sec_name = section name <asciiz> ;;
;> _key_name = key name <asciiz> ;;
;> _def_val = default value to return if no key, section, file found or incorrect string <dword> ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = [_def_val] (error) / number of option string in _option_list <dword> ;;
;;================================================================================================;;
stdcall ini.get_option_str, [_f_name], [_sec_name], [_key_name], _bool_strings_list, ini.MAX_BOOL_LEN, [_def_val]
and eax, 0x1
ret ret
endp endp
@ -757,7 +793,8 @@ export libini._.init , 'lib_init' , \
ini.get_str , 'ini_get_str' , \ ini.get_str , 'ini_get_str' , \
ini.get_int , 'ini_get_int' , \ ini.get_int , 'ini_get_int' , \
ini.get_color , 'ini_get_color' , \ ini.get_color , 'ini_get_color' , \
ini.get_option_str, 'ini_get_option_str', \
ini.get_bool , 'ini_get_bool' , \
ini.set_str , 'ini_set_str' , \ ini.set_str , 'ini_set_str' , \
ini.set_int , 'ini_set_int' , \ ini.set_int , 'ini_set_int' , \
ini.set_color , 'ini_set_color' , \ ini.set_color , 'ini_set_color' ;, \
ini.get_option_str, 'ini_get_option_str';, \

View File

@ -20,6 +20,7 @@
ini.MAX_NAME_LEN = 1024 ini.MAX_NAME_LEN = 1024
ini.MAX_VALUE_LEN = 4096 ini.MAX_VALUE_LEN = 4096
ini.MAX_BOOL_LEN = 9
ini.MEM_SIZE = 4096 ini.MEM_SIZE = 4096
ini.BLOCK_SIZE = ini.MEM_SIZE / 2 ini.BLOCK_SIZE = ini.MEM_SIZE / 2