aboutsummaryrefslogtreecommitdiffstats
path: root/plpfuse
diff options
context:
space:
mode:
authorReuben Thomas <rrt@sc3d.org>2007-12-15 16:08:36 +0000
committerReuben Thomas <rrt@sc3d.org>2007-12-15 16:08:36 +0000
commit722003826888760609a62e3015917cb46ada6fc9 (patch)
treeb71ef75f6f96bb368cd0580375e33c6113ca5b76 /plpfuse
parentd4021e62acb13c2869cbe577c59e8df2f4eba813 (diff)
downloadplptools-722003826888760609a62e3015917cb46ada6fc9.tar.gz
plptools-722003826888760609a62e3015917cb46ada6fc9.tar.bz2
plptools-722003826888760609a62e3015917cb46ada6fc9.zip
Fix up option-parsing code to cope with -p. Add a note about how it's
all kludged. Remove trace of old -u option.
Diffstat (limited to 'plpfuse')
-rw-r--r--plpfuse/main.cc33
1 files changed, 17 insertions, 16 deletions
diff --git a/plpfuse/main.cc b/plpfuse/main.cc
index d61e9ee..8689cae 100644
--- a/plpfuse/main.cc
+++ b/plpfuse/main.cc
@@ -267,15 +267,14 @@ help()
cerr << _(
"Usage: plpfuse [OPTION...] MOUNTPOINT\n"
"\n"
- "Supported options:\n"
+ "plpfuse options:\n"
"\n"
- " -u, --user=USER Specify USER who owns mounted dir\n"
- " -d, --debug Increase debugging\n"
- " -h, --help Display this text\n"
- " -V, --version Print version and exit\n"
- " -p, --port=[HOST:]PORT Connect to port PORT on host HOST\n"
- " Default for HOST is 127.0.0.1\n"
- " Default for PORT is "
+ " -d, --debug Increase debugging level\n"
+ " -h, --help Display this text\n"
+ " -V, --version Print version and exit\n"
+ " -p, --port=[HOST:]PORT Connect to port PORT on host HOST\n"
+ " Default for HOST is 127.0.0.1\n"
+ " Default for PORT is "
) << DPORT << "\n\n";
}
@@ -284,7 +283,6 @@ static struct option opts[] = {
{"debug", no_argument, 0, 'd'},
{"version", no_argument, 0, 'V'},
{"port", required_argument, 0, 'p'},
- {"user", required_argument, 0, 'u'},
{NULL, 0, 0, 0 }
};
@@ -337,17 +335,20 @@ int fuse(int argc, char *argv[])
}
int main(int argc, char**argv) {
- ppsocket *skt;
- ppsocket *skt2;
+ ppsocket *skt, *skt2;
const char *host = "127.0.0.1";
- int sockNum = DPORT;
- int i, c;
+ int sockNum = DPORT, i, c, oldoptind = 1;
struct servent *se = getservbyname("psion", "tcp");
endservent();
if (se != 0L)
sockNum = ntohs(se->s_port);
+ /* N.B. Option handling is kludged. Most of the options are shared
+ with FUSE, except for -p/--port, which has to be removed from
+ argv so that FUSE doesn't see it. Hence, we don't complain
+ about unknown options, but leave that to FUSE, and similarly we
+ don't quit after issuing a version or help message. */
opterr = 0; // Suppress errors from unknown options
while ((c = getopt_long(argc, argv, "hVp:d", opts, NULL)) != -1) {
switch (c) {
@@ -362,9 +363,9 @@ int main(int argc, char**argv) {
break;
case 'p':
parse_destination(optarg, &host, &sockNum);
- for (i = optind; i < argc - 1; i++)
- argv[i] = argv[i + 2];
- argc -= 2;
+ for (i = oldoptind; i < argc - (optind - oldoptind); i++)
+ argv[i] = argv[i + (optind - oldoptind)];
+ argc -= optind - oldoptind;
break;
}
}