MetalServe - Who needs Jazz when there's Metal?
 
MetalServe
 News 
 About 
 Features 
 Screenshots 
 FAQ 
 Mailing list 
 Contact 

Let's try it
 Requirements 
 License 

Docs
 Installation 
 IRC usage 
 Server connects 
 DCC sends 
 Logging 

Configfile
 Format 
 Reference 
 Example 

Developers
 Roadmap 
 Download 
 Config parser 
 Visions & ideas 

  

MetalServe configfile style

Here are some notes about the config parser used in MetalServe. See also two illustrations I made explaining the way it actually parses: Part 1, Part 2.

There are thousands of programs out there, and a nifty number of them reads parameters from some kind of configuration file. A handful different "styles" for configuration files has evolved, among them:

  • the style adopted by the Apache Webserver:

    # comment
    
    directive value
    
    another_directive value
    
    <section>
    	directive value
    </section>
    

    The format looks a bit like HTML or XML, but it isn't. It supports sections or contexts (ie. the impact of a directive depends on its place within the configuration file) and a directive may span multiple lines if the end of the line ends in a backslash.

  • the style used by common ircd IRC servers, probably inspired by the classical printcap format:

    # comment
    
    # the A directive
    A:some value:another argument:
    
    # the X directive
    X:value:
    

    This format is easy to parse since everything except comments and whitespace is ignored and all other lines can be easily divided into columns, using the colon ":" as seperator.

  • Windows' .ini style:

    ; comment
    
    [section]
    directive=value
    

    This format supports sections, but they can't be nested. All directives are at all times member of one section and there is nothing like a global section.

  • the style adopted by the bind Nameserver:

    # comment
    
    directive value;
    
    section {
    	directive value;
    };
    

    This format is clearly derived from the C programming language: you even need to terminate directives with a semicolon. It supports sections as well.

Having to deal with these formats may appear cumbersome to some, but it's how everything evolved. Here's a comparison of the styles, based on my own opinion:

Name Flexibibility Ease of use
Apache-style Good Good
Windows .ini style Acceptable Poor
ircd style Poor Poor
bind style Good Good

For MetalServe, I decided to use a variation of the bind format:

  • First of all, MetalServe does not require termination of directives with a semicolon. This looked like too much of a C-like restriction to me. Currently, a directive either has all its arguments on a single line, or, opens a subsection. This also means that we currently do not support the backslash as last character in a line to indicate that the next line contains further arguments.

  • You do not need to put multiple arguments within curled braces. The parser, depending on the directive, will either treat the entire argument as one or seperate the arguments using Space as argument seperator (unless escaping and quoting techniques are applied).

  • In MetalServe, sections can be nested, possibly resembling what may appear as object-oriented methodology: a network directive's section consists of channel and server directives, which in turn may open their own sections (see the example configuration file).

  • MetalServe's quoting and escaping behaviour is probably different. I haven't played enough with bind, but I just guess its parser uses different rules.

One might ask why I didn't use XML for the config file and used a 08/15 XML parser. The answer is simple: XML is intended as a portable means to exchange machine-readable data. XML documents contain too much cruft, making it not really nice to be edited by humans. MetalServe's configuration file is intended to be intuitive. And where it's not, the documentation is hopefully better, hehe...

 

Copyright © 1999-2006 by Pieter Hollants. All rights reserved.