diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2002-05-13 17:33:29 +0000 |
---|---|---|
committer | Marcus Brinkmann <marcus@gnu.org> | 2002-05-13 17:33:29 +0000 |
commit | aaba3eb39cc37d61ed3dac9f1c865b4ed2bf9997 (patch) | |
tree | 6cf49e318d2e46748c2b083f4e1ccd28df6255a8 | |
parent | a399edfb6d90e393dae578b46e9c3e4515535e6f (diff) |
2002-05-13 Marcus Brinkmann <marcus@gnu.org>
* symlink.c: Include <argp.h> and <version.h>.
(argp_program_version, options, args_doc, doc, argp): New
variables.
(parse_opt): New function.
(main): Replace argument count check and usage output by
argp_parse invocation.
-rw-r--r-- | trans/ChangeLog | 9 | ||||
-rw-r--r-- | trans/symlink.c | 40 |
2 files changed, 44 insertions, 5 deletions
diff --git a/trans/ChangeLog b/trans/ChangeLog index 9c4f1ea9..491b6db4 100644 --- a/trans/ChangeLog +++ b/trans/ChangeLog @@ -1,5 +1,14 @@ 2002-05-13 Marcus Brinkmann <marcus@gnu.org> + * symlink.c: Include <argp.h> and <version.h>. + (argp_program_version, options, args_doc, doc, argp): New + variables. + (parse_opt): New function. + (main): Replace argument count check and usage output by + argp_parse invocation. + +2002-05-13 Marcus Brinkmann <marcus@gnu.org> + * fakeroot.c (netfs_S_file_exec): New function. (netfs_S_io_prenotify): Fix last change. (netfs_S_io_postnotify): Likewise. diff --git a/trans/symlink.c b/trans/symlink.c index cc937e52..98abdfe3 100644 --- a/trans/symlink.c +++ b/trans/symlink.c @@ -19,10 +19,12 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <argp.h> #include <hurd/fsys.h> #include <fcntl.h> #include <errno.h> #include <error.h> +#include <version.h> #include "fsys_S.h" mach_port_t realnode; @@ -35,6 +37,37 @@ char *linktarget; extern int fsys_server (mach_msg_header_t *, mach_msg_header_t *); +const char *argp_program_version = STANDARD_HURD_VERSION (symlink); + +static const struct argp_option options[] = + { + { 0 } + }; + +static const char args_doc[] = "TARGET"; +static const char doc[] = "A translator for symlinks." +"\vA symlink is an alias for another node in the filesystem." +"\n" +"\nA symbolic link refers to its target `by name', and contains no actual" +" reference to the target. The target referenced by the symlink is" +" looked up in the namespace of the client."; + +/* Parse a single option/argument. */ +static error_t +parse_opt (int key, char *arg, struct argp_state *state) +{ + if (key == ARGP_KEY_ARG && state->arg_num == 0) + linktarget = arg; + else if (key == ARGP_KEY_ARG || key == ARGP_KEY_NO_ARGS) + argp_usage (state); + else + return ARGP_ERR_UNKNOWN; + return 0; +} + +static struct argp argp = { options, parse_opt, args_doc, doc }; + + int main (int argc, char **argv) { @@ -42,11 +75,8 @@ main (int argc, char **argv) mach_port_t control; error_t err; - if (argc != 2) - { - fprintf (stderr, "Usage: %s link-target\n", argv[0]); - exit (1); - } + /* Parse our options... */ + argp_parse (&argp, argc, argv, 0, 0, 0); task_get_bootstrap_port (mach_task_self (), &bootstrap); if (bootstrap == MACH_PORT_NULL) |