2213 bytes for the following functions :
reglib::get_num_key equ reglib@0000
;long value = reglib::get_num_key(const char *file, const char *section, const char *key, long default, const short *error)
;*file = name of the file which contains the searched key
; if *file doesn't exist, reglib will try to create it. In case of failure, reglib will return default value and error code will be REGLIB_FILE_NOT_FOUND
;*key = name of the searched key
; if *section doesn't exist, reglib will return default value and error code will be REGLIB_KEY_NOT_FOUND
; if *key doesn't exist, reglib will return default value and error code will be REGLIB_KEY_NOT_FOUND
;default = default value, which is returned in case of error (so, caller program doesn't need to catch errors)
;*error = pointer to short value, where the error will be stored
; if all is correct, *error = REGLIB_OK
reglib::add_num_key equ reglib@0001
;short error = reglib::add_num_key(const char *file, const char *section, const char *key, long value)
;*file = name of the file which contains the key to store
; if *file doesn't exist, reglib will try to create it. In case of failure, reglib will return default value and error code will be REGLIB_FILE_NOT_FOUND
;*key = name of the key to store
; if *section doesn't exist, reglib will create a new section
; if *key doesn't exist, reglib will create a new key
;value = value of the key
; if all is correct, error = REGLIB_OK
reglib::remove_key equ reglib@0002
;short error = reglib::remove_key(const char *file, const char *section, const char *key)
;*file = name of the file which contains the key to remove
; if *file doesn't exist, reglib will try to create it. In case of failure, reglib will return default value and error code will be REGLIB_FILE_NOT_FOUND
;*key = name of the key to remove
; if *section doesn't exist, the text remain unchanged.
; if *key doesn't exist, the text remain unchanged.
;after this function, *file is unarchived (even the searched key doesn't exist).
;if there is not enough memory to remove the key, error will be REGLIB_UNSAVED_FILE
; if all is correct, error = REGLIB_OK
reglib::get_string_key equ reglib@0003
;error = short reglib::get_string_key(const char *file, const char *section, const char *key, const char *value, long max_length, const char *default)
;*file = name of the file which contains the searched key
; if *file doesn't exist, reglib will try to create it. In case of failure, reglib will return default value and error code will be REGLIB_FILE_NOT_FOUND
;*key = name of the searched key
; if *section doesn't exist, reglib will return default value and error code will be REGLIB_KEY_NOT_FOUND
; if *key doesn't exist, reglib will return default value and error code will be REGLIB_KEY_NOT_FOUND
;*value = pointer where the result will be stored
;max_length = maximum length of the result. The *value buffer must be at least (max_length-bytes+1) long (+1 for the terminating zero)
;*default = default value, which is written in case of error
;error = pointer to short value, where the error will be stored
; if all is correct, error = REGLIB_OK
reglib::add_string_key equ reglib@0004
;short error = reglib::add_string_key(const char *file, const char *section, const char *key, const char *value)
;*file = name of the file which contains the key to store
; if *file doesn't exist, reglib will try to create it. In case of failure, reglib will return default value and error code will be REGLIB_FILE_NOT_FOUND
;*key = name of the key to store
; if *section doesn't exist, reglib will create a new key
; if *key doesn't exist, reglib will create a new key
;*value = pointer to the value (standard C string)
; if all is correct, error = REGLIB_OK
Example of valid text
#comment
key_1 = 212123
key_2 = "abcdedf"
[section_1]
key_1 = "kfjksdjfksdjfj"
variable = 5142
[section_2]
#comment
key_1 = 51212
key_2 = 1212015
I've done a small interface (with dialog boxes) to allow to test my functions : reglib is 3185 bytes large with its interface
Finally, do you like reglib for name or do you prefer another one ?