diff options
author | Roy Marples <roy@marples.name> | 2008-03-26 08:08:47 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2008-03-26 08:08:47 +0000 |
commit | be1f9b0a93ac3af0899fc7cf70ed7604dbc598a4 (patch) | |
tree | 23e21c017de1bcbe203306d7b26e9282f52bc5e3 /src | |
parent | e30ea10e6cb3d3eca370fdb22d479834ec3f86a4 (diff) |
Add --exists and --resolve to rc-service.
Diffstat (limited to 'src')
-rw-r--r-- | src/rc/rc-service.c | 20 |
1 files changed, 18 insertions, 2 deletions
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 } |