I want to write a unix/linux program, that will use a configuration file.
My problem is, where should I put the location of the file?
I could “hardcode” the location (like /etc) into the program itself.
However, I would like it, if the user without privileges could install it (through make) somewhere else, like ~.
Should the makefile edit the source code? Or is it usually done in a different way?
It is common to use a series of places to get the location:
./program -C path/to/config/file.cfg).char *path_to_config = getenv("PROGRAMCONFIG");).stat("./program.cfg")or build up a strig to specify either “$HOME/.program/config.cfg” or “$HOME/.program.cfg” andstatthat).stat("/etc/program/config.cfg",...)).