Hi all,
I'm looking for C source code (or for directions of how to write it if
there's no ready made code available) that processes an .ini file that
looks something like this:
...
[measuringparameters]
apparatus1.float_parameter1 = 3.45
apparatus2.int_parameter1 = 67
[standarddir]
defaultdir = C:\temp
...
I would like the program to behave in a way that it reads a line, and
then determines the variable it belongs to, and sets the value of the
variable accordingly (so not that it already knows the variable and
searches the .ini file line to go with it, but the other way around).
The idea is that I have some global structures with measuring
parameters, and that these ini files are used to initialize these
parameters as the program starts up (parameters that are not in the .ini
file remain uninitialized or get a hard coded default value). Until now
I used comma separated value-only .ini files
(234.54,3,6,1,filename,12,etc). However these are highly unflexible and
also hard to understand which number means what, you have to have a .txt
file that describes the ini file. If you insert a number in the wrong
place all hell breaks loose because all the remaining parameters will
get the wrong value. It is far more convenient to see what you are doing
if you want to alter a parameter in the file by hand, and that the order
of apprearance doesn't matter.
I know how to open files and read strings etc, but I have no clue how a
program can determine the name of the variable it has to assign the
value to, dependent on the string that has just been read.
So I need a function that goes something like (syntax may be wrong as
I'm not doing C that much, but just to get the idea across):
char variablename[] = "whatever.int.variable";
int value = 123;
assign(char *variablename, int value)
{
...???
// result: whatever.int.variable=123;
Quote:
}
If you have ready made source code, or directions on how I can find
templates for this somewhere, or directions for how to do this myself
they are highly appreciated.
(crossposted to comp.lang.c and comp.sources.wanted, de-crosspost
according to content)
Greetings,
Erwin Timmerman
--
"Tell you one thing, when your solid state parts wear out you can't play
rocket ship with any of them." - Twang (re tubes vs transistors)
Links to a lot of recording FAQs: http://www.*-*-*.com/