[gtkada] configuration files

Preben Randhol randhol at pvv.org
Tue May 28 12:14:05 CEST 2002


Stephen Leake <stephen_leake at acm.org> wrote on 28/05/2002 (11:45) :
> 
> Actually, for Windows I'd prefer an "ini" file. There are routines in
> Windex (my Win32 binding) for that (Windows officially calls them
> "profile" files). I prefer that over the registry because it is easier
> to maintain many copies. For example, one "ini" file for my Science
> Fiction books database, one for my wife's child therapy database, etc.
> 
> For the same reason, I would like to not use "dot files" on Unix.
> These are not "personal preferences", they are "application settings".
> They should be bound to the application, not the user.

Huh? I don't understand you. You just said you wanted different files
for different users? On Unix you cannot as a user write files outside of
your home directory so you need to maintain a local copy. 

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.

> I guess you can do the same thing with the registry, but I haven't
> seen it done that way. And it is much easier to backup an ini file
> than the registry.
>
> 
> Of course, if we can come up with one interface to both kinds of
> files, that would be good. The Windows "ini" file interface is
> actually both; if you specify a file name and directory, that is used,
> but the default is the Windows directory and win.ini.

I would like to keep the actual package as platform independant as
possible so I think that .ini file is best.
> 
> > If you do not find a general package for this purpose, then you can
> > count me in as a volunteer to help deciding on a package
> > specification and to help implementing a Unix version of the
> > package.
> 
> 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
> 
> I believe that can easily be implemented on any file system.
> 
> It would be nice to have a standard file syntax, as well as a standard
> API, so I can bundle a default or example profile file with an app,
> and it would work for any OS.

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...



-- 
Preben Randhol ------------------- http://www.pvv.org/~randhol/ --
                 «For me, Ada95 puts back the joy in programming.»




More information about the gtkada mailing list