aboutsummaryrefslogtreecommitdiffstats
path: root/dyndhcpd.c
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2014-06-07 07:10:03 +0200
committerGravatar Christian Hesse <mail@eworm.de>2014-06-07 07:10:03 +0200
commitff9711d3d89dda49641e9ccc66515fb4b2301312 (patch)
tree44a744644f2a34b71b6da6ed2cf234f6ef1de516 /dyndhcpd.c
parent16642157bebd6c691207dd0e4ed5f1a2830bd316 (diff)
downloaddyndhcpd-ff9711d3d89dda49641e9ccc66515fb4b2301312.tar.gz
dyndhcpd-ff9711d3d89dda49641e9ccc66515fb4b2301312.tar.zst
allow to use different template
Diffstat (limited to 'dyndhcpd.c')
-rw-r--r--dyndhcpd.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/dyndhcpd.c b/dyndhcpd.c
index 1794831..48e80fb 100644
--- a/dyndhcpd.c
+++ b/dyndhcpd.c
@@ -76,6 +76,7 @@ int main(int argc, char ** argv) {
char * domainname;
struct hostent *hp;
+ char * config_template = NULL;
size_t fsize;
char * config = NULL;
char * filename = NULL;
@@ -85,10 +86,17 @@ int main(int argc, char ** argv) {
printf("Starting dyndhcpd/" VERSION " (compiled: " __DATE__ ", " __TIME__ ")\n");
/* get command line options */
- while ((i = getopt(argc, argv, "hi:v")) != -1)
+ while ((i = getopt(argc, argv, "c:hi:v")) != -1)
switch (i) {
+ case 'c':
+ config_template = optarg;
+ if (strlen(config_template) == 0) {
+ fprintf(stderr, "Requested different config file, but no name given.\n");
+ return EXIT_FAILURE;
+ }
+ break;
case 'h':
- fprintf(stderr, "usage: %s [-h] -i INTERFACE [-v]\n", argv[0]);
+ fprintf(stderr, "usage: %s [-c config] [-h] -i INTERFACE [-v]\n", argv[0]);
return EXIT_SUCCESS;
case 'i':
interface = optarg;
@@ -202,9 +210,10 @@ int main(int argc, char ** argv) {
"Netmask: %s\n"
"Hosts: %s - %s\n", interface, domainname, c_address, c_netaddress, c_broadcast, c_netmask, c_minhost, c_maxhost);
-
/* open the template for reading */
- if ((configfile = fopen(CONFIG_TEMPLATE, "r")) == NULL) {
+ if (config_template == NULL)
+ config_template = CONFIG_TEMPLATE;
+ if ((configfile = fopen(config_template, "r")) == NULL) {
fprintf(stderr, "Failed opening config template for reading.\n");
goto out;
}