6185db853e024a486ff8837e6784dd290d866112dougm * CDDL HEADER START
6185db853e024a486ff8837e6784dd290d866112dougm * The contents of this file are subject to the terms of the
6185db853e024a486ff8837e6784dd290d866112dougm * Common Development and Distribution License (the "License").
6185db853e024a486ff8837e6784dd290d866112dougm * You may not use this file except in compliance with the License.
6185db853e024a486ff8837e6784dd290d866112dougm * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
6185db853e024a486ff8837e6784dd290d866112dougm * See the License for the specific language governing permissions
6185db853e024a486ff8837e6784dd290d866112dougm * and limitations under the License.
6185db853e024a486ff8837e6784dd290d866112dougm * When distributing Covered Code, include this CDDL HEADER in each
6185db853e024a486ff8837e6784dd290d866112dougm * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
6185db853e024a486ff8837e6784dd290d866112dougm * If applicable, add the following below this CDDL HEADER, with the
6185db853e024a486ff8837e6784dd290d866112dougm * fields enclosed by brackets "[]" replaced with your own identifying
6185db853e024a486ff8837e6784dd290d866112dougm * information: Portions Copyright [yyyy] [name of copyright owner]
6185db853e024a486ff8837e6784dd290d866112dougm * CDDL HEADER END
549ec3fff108310966327d1dc9004551b63210b7dougm * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
6185db853e024a486ff8837e6784dd290d866112dougm * Use is subject to license terms.
6185db853e024a486ff8837e6784dd290d866112dougm#pragma ident "%Z%%M% %I% %E% SMI"
549ec3fff108310966327d1dc9004551b63210b7dougmstatic int run_command(char *, int, char **, char *, sa_handle_t);
6185db853e024a486ff8837e6784dd290d866112dougm (void) printf(gettext("usage: sharemgr [-h | <command> [options]]\n"));
6185db853e024a486ff8837e6784dd290d866112dougm * make sure locale and gettext domain is setup
6185db853e024a486ff8837e6784dd290d866112dougm * parse enough of command line to get protocol, if any.
6185db853e024a486ff8837e6784dd290d866112dougm * Note that options need to come "after" the subcommand.
6185db853e024a486ff8837e6784dd290d866112dougm if (strcmp(command, "share") != 0 && strcmp(command, "unshare") != 0) {
25a68471b9ababbc21cfdbbb2866014f34f419ecdougm switch (c) {
6185db853e024a486ff8837e6784dd290d866112dougm /* no subcommand */
6185db853e024a486ff8837e6784dd290d866112dougm * now have enough to parse rest of command line
7d968cb8b4b6274092771b93e94bf88d1ee31c6cdougm * First, initialize the plugin architecture.
7d968cb8b4b6274092771b93e94bf88d1ee31c6cdougm * Plugins are needed in the event of a global help
7d968cb8b4b6274092771b93e94bf88d1ee31c6cdougm * reset optind to 1 so the parsing that takes place in
7d968cb8b4b6274092771b93e94bf88d1ee31c6cdougm * sa_init() will work correctly.
7d968cb8b4b6274092771b93e94bf88d1ee31c6cdougm * reset optind again since we will start parsing all over in
7d968cb8b4b6274092771b93e94bf88d1ee31c6cdougm * the sub-commands.
549ec3fff108310966327d1dc9004551b63210b7dougm rval = run_command(command, argc, argv, protocol, handle);
549ec3fff108310966327d1dc9004551b63210b7dougmrun_command(char *command, int argc, char *argv[], char *proto,
6185db853e024a486ff8837e6784dd290d866112dougm * To get here, we know there should be a command due to the
6185db853e024a486ff8837e6784dd290d866112dougm * preprocessing done earlier. Need to find the protocol
6185db853e024a486ff8837e6784dd290d866112dougm * that is being affected. If no protocol, then it is ALL
6185db853e024a486ff8837e6784dd290d866112dougm * protocols.
6185db853e024a486ff8837e6784dd290d866112dougm * We don't currently use the protocol here at this point. It
6185db853e024a486ff8837e6784dd290d866112dougm * is left in as a placeholder for the future addition of
6185db853e024a486ff8837e6784dd290d866112dougm * protocol specific sub-commands.
6185db853e024a486ff8837e6784dd290d866112dougm * Known sub-commands are handled at this level. An unknown
6185db853e024a486ff8837e6784dd290d866112dougm * command will be passed down to the shared object that
6185db853e024a486ff8837e6784dd290d866112dougm * actually implements it. We can do this since the semantics
6185db853e024a486ff8837e6784dd290d866112dougm * of the common sub-commands is well defined.
6185db853e024a486ff8837e6784dd290d866112dougm (void) printf(gettext("command %s not found\n"), command);
6185db853e024a486ff8837e6784dd290d866112dougm * need to check priviledges and restrict what can be done
6185db853e024a486ff8837e6784dd290d866112dougm * based on least priviledge and sub-command so pass this in
6185db853e024a486ff8837e6784dd290d866112dougm * as a flag.