[ccan] Configuration file parser?

Tim Post echo at echoreply.us
Wed Jan 28 20:09:22 EST 2009


Hi,

Does anyone have a small library (parser included) to parse the
following types of configuration files:

** Example 1 **

lockfile = /var/foo/shemp-is-technically-a-stooge.pid
lock_mem = true

** Example 2 **

daemon {
    lockfile = (...)
    lock_mem = true
}

** Example 3 **

daemon {
    behavior {
      threads = true;
      max_threads = 100;
    }

    logging {
      type = syslog;
      loglevel = 3;
    }
}

clients {
    allow {
       127.0.0.1 = rw
       127.0.0.2 = ro
    }
    deny = all
}

I have been (for over a year) trying to think of a way to make something
to parse the above sane and easy to use. I have always just gone with
XML when I need something more complex than example #1.

But, I want to be kind to system administrators, who quite often do not
appreciate hand editing XML configuration files.

I've looked all over the place for something that simplifies this
because I tend to sneeze uncontrollably every time I get near flex or
bison. So, if there's a wish list for ccan, please add this to it :)

Surely, it would be no big deal if the types shown above were predicated
with:

# cfg-parser type=xx (where xx is the type expected)

Cheers,
--Tim
 




More information about the ccan mailing list