[gtkada] configuration files

Stephen Leake stephen_leake at acm.org
Wed May 29 02:02:27 CEST 2002


Preben Randhol <randhol at pvv.org> writes:

> Huh? I don't understand you. You just said you wanted different files
> for different users? 

No, I didn't. I'm one user, and I want different files for different
databases. Sorry to be misleading.

> On Unix you cannot as a user write files outside of your home
> directory so you need to maintain a local copy.

True. But there will still be times when one user will want to have
more than one config file for a particular application. For example,
for a Tetris game, one config file that makes it easy to win (when
you've had a bad week), and one that makes it challenging.

> Let's say your program is called myadadb
> 
> The way it works is that you make a /etc/myadadb/ and in this directory
> you put the standard "factory"-default settings.
> 
> Then on the user side you can either have the program generate a myadadb
> directory or a .myadadb directory depending on your liking. In this
> directory you store the user settings and other files that the program
> needs.

Yes, but if I have two distinct databases, both accessed by 'myadadb',
then I need two distinct config files. I can use /etc/myadadb/.myadadb
and ~/.myadadb as defaults, but I also need a way to specify any
arbitrary name (perhaps as a command line parameter).

> I would like to keep the actual package as platform independant as
> possible so I think that .ini file is best.

Well, there are other possible formats that are platform independent.
For example, X windows stores stuff like this in a similar format; I
have not looked at it in detail.

> > Let's take the Windex Profiles API as a starting point:
> > 
> > http://users.erols.com/leakstan/Stephe/Ada/Windex_Packages/index.htm
> > 
> > file windex-profiles.ads
> > 
> 
> Why do we need:
> 
>  generic
>       type Modular_Type is mod <>;
>    function Read_Modular
>       (File    : in String;
>        Section : in String;
>        Keyword : in String;
>        Default : in Modular_Type)
>        return Modular_Type;
>    -- Return unsigned integer value associated with Keyword from Section in File. If
>    -- Keyword is not found, Default is returned.
> 
>    generic
>       type Modular_Type is mod <>;
>    procedure Write_Modular
>       (File    : in String;
>        Section : in String;
>        Keyword : in String;
>        Item    : in Modular_Type);
>    -- Write unsinged integer value Item to Keyord in Section in File.
> 
> etc...

Because they are useful. I have written applications that stored such
data in files, so these routines are here. I like keeping things
strongly typed, so I want more than just String, Float, Integer in
config files.

-- 
-- Stephe





More information about the gtkada mailing list