Program name : ConfLib 1.00b1 (Public beta) Author : Flanker (Matthieu Gallet) Date : 11/07/2004 Mail : matthieu_gallet at yahoo.fr Type : dynamic library for kernel-based programs Calculators : TI-89, TI-92Plus, Voyage 200 (all hardware and software versions) (requires PreOS 0.71 or higher) ConfLib is a library which deals with Conf files : you can insert or get any value (long integer or string) in TEXT files. **** There are 5 available functions **** long value = conflib::get_num_key(const char *file, const char *section, const char *key, long default, const short *error) short error = conflib::add_num_key(const char *file, const char *section, const char *key, long value) short error = conflib::remove_key(const char *file, const char *section, const char *key) short error = conflib::get_string_key(const char *file, const char *section, const char *key, const char *value, long max_length, const char *default) short error = conflib::add_string_key(const char *file, const char *section, const char *key, const char *value) the different values for error are self-explained : CONFLIB_OK equ 0 CONFLIB_FILE_NOT_FOUND equ 1 CONFLIB_KEY_NOT_FOUND equ 2 CONFLIB_INVALID_KEY equ 3 CONFLIB_UNSAVED_FILE equ 4 CONFLIB_UNARCHIVED_FILE equ 5 CONFLIB_CANT_CREATE_FILE equ 6 CONFLIB_SECTION_NOT_FOUND equ 7 file is a TEXT file which must be located in the SYSTEM folder defined by the kernel ('main' by default) If it already exists but it isn't a TEXT, ConfLib will return CONFLIB_FILE_NOT_FOUND It it doesn't exist, ConfLib will create it. It ConfLib writes in this file and it was archived, it will be re-archived after a succesful write. Don't specify the folder (i.e. don't type conflib::get_num_key("folder\file", ... but conflib::get_num_key("file", ...) Perhaps I will change this (the searched folder will be the system folder only if it isn't specified) For a more precise description of the avalaible functions, please take a look on the ConfLib.h header files. **** Note for assembly programmers **** All the registers except d0.l are preserved Parameters are pushed on the stack, like traditional C functions **** Thanks to **** the yAronet members (especially Godzil, PpHd, Pollux, Squale, Spectras, Uther) for their comments and for their help **** History **** 15/10/2004 : beginning 09/11/2004 : First public release **** Disclaimer - License **** I cannot be held responsible for any damages and/or data loss resulting directly or indirectly from the use of ConfLib. You are not allowed to re-distribute this package or any part of it without my authorization. The source code is provided for your curiosity, and to let you help me improve the program. But please ask me before using any part of it in your programs. **** Format of the text file **** * comments are accepted : a line is a comment if it begins by a '#' character * spaces are accepted in front of a key and around the '=' sign, but NOT at the end of a line * strings are delimited by '"' characters any valid variable name begins by _, a-z or A-Z and contains only characters among _, a-z, A-Z and 0-9. Its length is arbitrary. any valid section name begins by _, a-z or A-Z and contains only characters among _, a-z, A-Z and 0-9. Its length is inferior or equal to 16 chars. exemple of correct conf file : ----------------------------------------------------------- #comment 1 key_1 = 45312 key_2= 545 key_4 =0121647 [section_1] another_key = "string" #another comment [section_2] key_1 = "Hello, world" key_2 = "I'm Flanker" conflib::get_num_key("file","section_1","another_key",12,&error) will return 12 and error = CONFLIB_INVALID_KEY conflib::get_num_key("file","","key_1",12,&error) will return 45312 and error = CONFLIB_OK conflib::get_string_key("file","section_2","key_1",*value,10,*default) will return CONFLIB_OK and value = "Hello, world" ----------------------------------------------------------- examples of incorrect files : (spaces after the key value) ----------------------------------------------------------- key = 755545 ----------------------------------------------------------- (comment after a key) ----------------------------------------------------------- key = 5451212#comment ----------------------------------------------------------- ("" character int he middle of a string) ----------------------------------------------------------- key="strings"strings" -----------------------------------------------------------