Introduction
Introduction Statistics Contact Development Disclaimer Help
fix arg parsing - sdhcp - simple dhcp client
git clone git://git.codemadness.org/sdhcp
Log
Files
Refs
LICENSE
---
commit b9a0a3e1c7b194f9c82015a03cfe05fb4286d98f
parent 983d3375adcee59bf8acc476e0e6260bcbb88ce8
Author: Hiltjo Posthuma <[email protected]>
Date: Fri, 25 Apr 2014 22:13:25 +0200
fix arg parsing
Signed-off-by: Hiltjo Posthuma <[email protected]>
Diffstat:
M sdhcp.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/sdhcp.c b/sdhcp.c
@@ -304,7 +304,8 @@ static void
acceptlease(void)
{
setip(client, mask, router);
- setdns(dns);
+ if(dflag == 1)
+ setdns(dns);
alarm(t1);
}
@@ -406,7 +407,7 @@ static void cleanexit(int unused) {
static void
usage(void) {
- eprintf("usage: sdhcp [ifname] | [[-i] <ifname>] [-r] [-c <clientid>]\…
+ eprintf("usage: sdhcp [ifname] | [[-i] <ifname>] [-d] [-c <clientid>]\…
}
int
@@ -419,7 +420,7 @@ main(int argc, char *argv[])
ARGBEGIN {
case 'c': /* client-id */
- strlcpy(cid, EARGF(usage()), sizeof(cid));
+ cid = EARGF(usage());
break;
case 'i': /* interface */
ifname = EARGF(usage());
@@ -432,10 +433,10 @@ main(int argc, char *argv[])
break;
} ARGEND;
- if(argc == 2)
- usage();
- else if(argc == 1)
+ if(argc >= 1)
ifname = argv[0];
+ if(argc >= 2)
+ cid = argv[1];
memset(&ifreq, 0, sizeof(ifreq));
signal(SIGALRM, nop);
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.