NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

reading config files from C



Hi, I would like to introduce configuration files to a software
project I am supporting with build infrastructure. The C programs
depend on quite a few libraries from different sources. As a result of
development evolution, we have hardcoded paths in the source which
would be better served as parameters read from configuration files, so
the location of dependencies can be adjusted without modifying the
code. We need this functionality for runtime as well as compile time.

I've gotten started in the makefile with:
version ?= dev
include conf/default.mk
include conf/$(version).mk

which allows for a single line conf/dev.mk file to reconfigure a
longer ./conf/default.mk file.

This must be a programming pattern in C code with lots of templates to
choose from? It would also be nice to see an example of searching
$(dirname "$0")/conf/program.conf $HOME/program.conf /etc/program.conf
for inputs.

I've seen this pattern in various program ktrace outputs, and expected
an easy to find a solution with google. Until, I realized reverse
engineering source code might be more straightforward.

Does anyone have an example program recommendation or documentation
for this programming?

-George




I'm supporting a software project

-- 
George Georgalis, (415) 894-2710, http://www.galis.org/


Home | Main Index | Thread Index | Old Index