|FlexiLib - Flexible Input Library|
Many (scientific) computer programs are generally not being run in an interactive mode but read all the necessary parameter settings from one or more input files. The purpose of FlexiLib is to simplify the process of programming an input interface and to provide a good degree of flexibility for both the programmer and the user of the interface.
The main concept of FlexiLib are "keys-blocks" which can occur at any position in the input file. The order of data within each key-block is fixed by the programmer. Keys which were not requested by the program are ignored. Thus it is possible to activate and de-activate a whole block just by changing the key. Together with multiple scans through the input file this is a very flexible concept.
|Download & Install|
Just click on
FlexiLib-Aleph.tgzand download the package. Type
tar xzvf FlexiLib-Aleph.tgzto unpack or, alternatively, gunzip and untar the file in two separate steps. This creates a directory named
FlexiLibwhich contains all the files. Change into this directory and customize the
makefile. Then type
makewhich should leave you with the library file
int flexi_request_key(char *key, int required, char *fmt, ...);A key-block is requested. If no key-block with this key exists a new key-block is created. In the case that there already exists a key-block with the same key the new arguments of this call will be added to the end of the existing key-block. The format string 'fmt' determines the types and sequence of the expected data of the key-block and uses the same format as that of the standard C library for the
scanfcalls. The variable argument list after 'fmt' expects pointers to the corresponding variables. The call returns 0 if no problem was detected and 1 if there were less arguments in the list than 'fmt' required. The flag required=1 marks the key-block as required in which case the returned value of
flexi_gather_keys()will depend on whether this key was resolved or not.
int flexi_gather_keys(FILE *fp);
Scans through the file 'fp' and reads the key-block data when a previously requested key is found. See the 'Input File Format' section for details on the input file. The corresponding arguments are set to those found at the last matching key in 'fp'. Returns the number of currently requested and required keys that could not be resolved in 'fp'.
int flexi_resolved_key(char *key);
Check whether a certain key-block was resolved by a previous 'flexi_gather_keys()' call. If so 1 is returned by the call. If the key-block could not be resolved, either because the key was not found or because the key-block data was incomplete, the call returns 0. If 'key' is not among the currently requested keys a -1 will be returned.
All currently requested key-blocks are cleared so that after this call no keys are requested.
|Input File Format|
Bear these things in mind when creating input files for FlexiLib:
- Key-blocks start with the corresponding key which has to be set between '[' and ']' characters.
- The sequence and type of data following a certain key is fixed by the key request and needs to be considered.
- Everything appearing after a '#' character will be considered a comment until the end of the line.
'FlexiLib' - Flexible Input Library
Copyright (C) 2000 Gerhard J. Theurich (gjt)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA