From be1f9b0a93ac3af0899fc7cf70ed7604dbc598a4 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Wed, 26 Mar 2008 08:08:47 +0000 Subject: Add --exists and --resolve to rc-service. --- src/rc/rc-service.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/rc') diff --git a/src/rc/rc-service.c b/src/rc/rc-service.c index e7bd62c8..d3f52b0d 100644 --- a/src/rc/rc-service.c +++ b/src/rc/rc-service.c @@ -43,9 +43,11 @@ extern char *applet; #include "_usage.h" -#define getoptstring "l" getoptstring_COMMON +#define getoptstring "e:lr:" getoptstring_COMMON static const struct option longopts[] = { - { "list", 0, NULL, 'l' }, + { "exists", 1, NULL, 'e' }, + { "list", 0, NULL, 'l' }, + { "resolve", 1, NULL, 'r' }, longopts_COMMON }; static const char * const longopts_help[] = { @@ -68,6 +70,12 @@ int rc_service(int argc, char **argv) longopts, (int *) 0)) != -1) { switch (opt) { + case 'e': + service = rc_service_resolve(optarg); + opt = service ? EXIT_SUCCESS : EXIT_FAILURE; + free(service); + return opt; + /* NOTREACHED */ case 'l': list = rc_services_in_runlevel(NULL); if (! list) @@ -78,6 +86,14 @@ int rc_service(int argc, char **argv) rc_stringlist_free(list); return EXIT_SUCCESS; /* NOTREACHED */ + case 'r': + service = rc_service_resolve(optarg); + if (!service) + return EXIT_FAILURE; + printf("%s\n", service); + free(service); + return EXIT_SUCCESS; + /* NOTREACHED */ case_RC_COMMON_GETOPT } -- cgit v1.2.3