summaryrefslogtreecommitdiff
path: root/trans/symlink.c
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus@gnu.org>2002-05-13 17:33:29 +0000
committerMarcus Brinkmann <marcus@gnu.org>2002-05-13 17:33:29 +0000
commitaaba3eb39cc37d61ed3dac9f1c865b4ed2bf9997 (patch)
tree6cf49e318d2e46748c2b083f4e1ccd28df6255a8 /trans/symlink.c
parenta399edfb6d90e393dae578b46e9c3e4515535e6f (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.
Diffstat (limited to 'trans/symlink.c')
-rw-r--r--trans/symlink.c40
1 files changed, 35 insertions, 5 deletions
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)