11 Feb 2004 oku   » (Journeyer)

New Project

I am currently working on a new project. It is just an idea, and let's see how far it goes: you all know about the diversity of configuration files in Unix, it seems that every program has its own syntax. This makes it difficult to write configuration editors for web interfaces or GUI configuration editors.I do not think that much can be done about it, it is nearly impossible to convert each program's configuration file to a single, unified format. But still, most, if not all have one thing in common: they can be represented as trees, with the values as its leaves. See eg. /etc/network/interfaces. If it looks like:

auto eth0

iface eth0 inet static address netmask gateway

this can be represented in a tree:


iface eth0 family 'inet' method 'static' address '' gateway ''

So we could write a parser that reads a conf file and represents it internally as a tree. Each entry can than be accessed in a file system like manner, eg. the address of eth0 with


The same can be done with other conf files, eg, XF86Config-4, dhcpd.conf etc. What we then need is a common way to access and modify the tree. This can be simple commands that are called from shell scripts or functions in for example C. To get the address of eth0 in a shell script, we could write:

cnf ifupdown get iface/eth0/address
And the same for XFree86, for example to get the device file for the mouse:
cnf xfree86 get InputDevice/Device
In the latter example, we may have ambiguities, I have two mouse devices. So a real script would have to check the Identifier.

So this way it is possible for shell scripts to get the IP address or other values for an interface easily, and different configuration editors can rely on a unified library to access and modify data.

Of course, this approach does not make it easy as pie: it is still necessary to write a parser, and to change values, also an 'unparser' that writes the data back, without loosing any changes that are not understood, and if possible, also any comments that have been made in the fille. That's why I do not know yet how far this project will get.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!