Hello, I guess this may have been discussed many times, but after a quick search in the forum, I could not find any thread about it (but it was a really quick search ...).
OpenSolaris, as well as most (all ?) unixes, uses configuration files for many applications. All applications needing some configuration data use a config file, either located, in general, in /etc, or ~/.appname/xxx.conf. That may be a lot of config files. When an app needs to read or write its config file, it needs to parse it. I don't know how applications use to do this, but I've read as an example http://cvs.opensolaris.org/source/xref/on/usr/src/cmd/xntpd/xntpd/ntp_config.c where the config file reading/parsing is done inside the ntp_config.c file. Since many (most ?) config files may be something like : # some comments param1 = arg1 param2 = arg2 param3 = arg3 # another comment param4 = arg4 why not having a lib function that would help parsing/reading/writing such a file ? With a configuration file such as the example above, one could think about a function that would return the value of arg1 arg = cfgfile_readparam("/file/location",param1) We could also have a function to write the conf cfgfile_writeparam("/file/location",param1,newarg1) cfgfile_replaceparam("/file/location",param2,newarg2) cfgfile_addcomment(....) etc ... That'd avoid the need to write in all aplication the code to read/write parameters in configuration files. Of course, some configuration files would need some more complex things. I can't think about one right now, but I can imagine that paramX=argX would not fit all needs. Thus maybe writing config files with an XML format would help ? Furthermore, as I said before, there may be a lot of config files. Why not have ALL configuration into a single file ? That could be a hash, a berkeleydb file (I think E17 uses such files for conf), or whatever. (isn't it the way MS Win does with is registry ?) For files needed by everyone, this file would be /config (or /etc/config), for personnal config that could be ~/config. Thus only two locations for all configs. Into applications, the lib functions would permit to use them (read, write, update ...), and a command line tool could do the same within a shell. cfgfile -update -app myapp -param "thisparam" -arg "this_arg" cfgfile -printarg -app myapp -param "anotherparam" ... Any comment, idea ? Has something similar allready been done or discussed ? Thank you Yann This message posted from opensolaris.org _______________________________________________ opensolaris-discuss mailing list opensolaris-discuss@opensolaris.org