From: Roy Marples Date: Mon, 5 Jan 2009 08:20:53 +0000 (+0000) Subject: Allow version to be returned over the control interface. X-Git-Tag: v5.0.0~136 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f367dc38be67d6e165780f91bf554faf1030443f;p=thirdparty%2Fdhcpcd.git Allow version to be returned over the control interface. --- diff --git a/control.c b/control.c index 9ea2a55d..185638ff 100644 --- a/control.c +++ b/control.c @@ -1,6 +1,6 @@ /* * dhcpcd - DHCP client daemon - * Copyright 2006-2008 Roy Marples + * Copyright 2006-2009 Roy Marples * All rights reserved * Redistribution and use in source and binary forms, with or without @@ -84,7 +84,7 @@ handle_control_data(void *arg) *ap++ = p; p += strlen(p) + 1; } - handle_args(argc, argvp); + handle_args(*s, argc, argvp); } } diff --git a/dhcpcd.c b/dhcpcd.c index aa2a6020..7ef6ae5b 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -1098,11 +1098,18 @@ handle_signal(_unused void *arg) } int -handle_args(int argc, char **argv) +handle_args(int fd, int argc, char **argv) { struct interface *ifs, *ifp, *ifl, *ifn, *ift; int do_exit = 0, do_release = 0, do_reboot = 0, opt, oi = 0; + if (strcmp(*argv, "--version") == 0) { + if (fd != -1) { + write(fd, VERSION, strlen(VERSION)); + return 0; + } + } + optind = 0; while ((opt = getopt_long(argc, argv, IF_OPTS, cf_options, &oi)) != -1) { diff --git a/dhcpcd.h b/dhcpcd.h index 0bcb280d..21a3f4c2 100644 --- a/dhcpcd.h +++ b/dhcpcd.h @@ -113,7 +113,7 @@ extern int ifdc; extern char **ifdv; extern struct interface *ifaces; -int handle_args(int, char **); +int handle_args(int, int, char **); void handle_exit_timeout(void *); void start_interface(void *); void start_discover(void *);