Linux Hotplug development
 help / color / mirror / Atom feed
* [PATCH] Print usage of udevcontrol when no or invalid command is given
@ 2006-07-02 16:59 Tobias Klauser
  2006-07-02 23:06 ` [PATCH] Print usage of udevcontrol when no or invalid command Kay Sievers
  0 siblings, 1 reply; 2+ messages in thread
From: Tobias Klauser @ 2006-07-02 16:59 UTC (permalink / raw)
  To: linux-hotplug

When not giving any command to udevcontrol it just prints "missing command".
This patch changes udevcontrol to also print the usage in such cases (and
additionaly in cases where invalid commands are given).

The patch also cleans up the exit paths.

---
 udevcontrol.c |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/udevcontrol.c b/udevcontrol.c
index 8add09e..60d21d2 100644
--- a/udevcontrol.c
+++ b/udevcontrol.c
@@ -33,6 +33,9 @@ #include <sys/un.h>
 #include "udev.h"
 #include "udevd.h"
 
+/* prototypes */
+void usage(void);
+
 /* global variables */
 static int sock = -1;
 static int udev_log = 0;
@@ -51,6 +54,16 @@ void log_message (int priority, const ch
 }
 #endif
 
+void usage(void)
+{
+	printf("Usage: udevcontrol COMMAND\n"
+		"  log_priority=<level> set the udev log level for the daemon\n"
+		"  stop_exec_queue      keep udevd from executing events, queue only\n"
+		"  start_exec_queue     execute events, flush queue\n"
+		"  reload_rules         reloads the rules files\n"
+		"  max_childs=<N>       maximum number of childs running at the same time\n"
+		"  --help               print this help text\n\n");
+}
 
 int main(int argc, char *argv[], char *envp[])
 {
@@ -72,6 +85,7 @@ int main(int argc, char *argv[], char *e
 
 	if (argc < 2) {
 		fprintf(stderr, "missing command\n\n");
+		usage();
 		goto exit;
 	}
 
@@ -100,23 +114,18 @@ int main(int argc, char *argv[], char *e
 			*intval = atoi(val);
 			info("send max_childs=%i", *intval);
 		} else if (strcmp(arg, "help") = 0  || strcmp(arg, "--help") = 0  || strcmp(arg, "-h") = 0) {
-			printf("Usage: udevcontrol COMMAND\n"
-				"  log_priority=<level> set the udev log level for the daemon\n"
-				"  stop_exec_queue      keep udevd from executing events, queue only\n"
-				"  start_exec_queue     execute events, flush queue\n"
-				"  reload_rules         reloads the rules files\n"
-				"  max_childs=<N>       maximum number of childs running at the same time\n"
-				"  --help               print this help text\n\n");
-			exit(0);
+			usage();
+			goto exit;
 		} else {
 			fprintf(stderr, "unknown option\n\n");
-			exit(1);
+			usage();
+			goto exit;
 		}
 	}
 
 	if (getuid() != 0) {
 		fprintf(stderr, "need to be root, exit\n\n");
-		exit(1);
+		goto exit;
 	}
 
 	sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
-- 
1.4.0


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid\x120709&bid&3057&dat\x121642
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-07-02 23:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-02 16:59 [PATCH] Print usage of udevcontrol when no or invalid command is given Tobias Klauser
2006-07-02 23:06 ` [PATCH] Print usage of udevcontrol when no or invalid command Kay Sievers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox