Reading namelist style




	Dear friends,

	I'm writing a C application using gtk. At some point of the
application a read an "input" file with a set of variables in fortran
namelist style. For example, if I have to read the three strings and
assign them to the variables "name", "surname" and "address" the input
file could be something like:
	
	&namelist1 name='Bill' surname='Clinton' address='White House'/
	
	Here "namelist1" is the name of the namelist, and the
symbols "&" and "/" delimitate the begining and end of the list of
variables associated to the namelist "namelist1". Some of the variables
of the namelist may not appear in the input file, in which case a
default value is assigned. For example, in the namelist

	&namelist1 name='Monica' surname='Lewinsky' /

	the program could assign the value 'unknown' to the variable
"address".
 
	In the application I have to read about 10 namelists, each one
containing a number of variables between 10 and 100. The program should allocate 
dynamically the memory for these variables (as the lenght of the arrays
is not known since they are not read). So the number of variables to be read is large in general but
they can be "destroyed" after reading the input file, as the content of
each variable will be placed on a different widget (i.e. entry box).

	 I know that glib contains many subroutines designed to facilitate
the use of arrays, strings and memory allocation, that may be helpful to
solve my problem in an elegant and optimum fashion. Unfortunally I am not
very familiarized with these subroutines.

	Could anybody suggest any hint? 

							Thanks,
				
							Antonio Moro 

							



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]