17836SJohn.Forte@Sun.COM /*
27836SJohn.Forte@Sun.COM * CDDL HEADER START
37836SJohn.Forte@Sun.COM *
47836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the
57836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License").
67836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License.
77836SJohn.Forte@Sun.COM *
87836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing.
107836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions
117836SJohn.Forte@Sun.COM * and limitations under the License.
127836SJohn.Forte@Sun.COM *
137836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
147836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
167836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
177836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
187836SJohn.Forte@Sun.COM *
197836SJohn.Forte@Sun.COM * CDDL HEADER END
207836SJohn.Forte@Sun.COM */
217836SJohn.Forte@Sun.COM /*
229087SZhong.Wang@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
237836SJohn.Forte@Sun.COM * Use is subject to license terms.
247836SJohn.Forte@Sun.COM */
257836SJohn.Forte@Sun.COM
267836SJohn.Forte@Sun.COM #include <fcinfo.h>
277836SJohn.Forte@Sun.COM
287836SJohn.Forte@Sun.COM
297836SJohn.Forte@Sun.COM
307836SJohn.Forte@Sun.COM #define VERSION_STRING_MAX_LEN 10
317836SJohn.Forte@Sun.COM /*
327836SJohn.Forte@Sun.COM * Version number:
337836SJohn.Forte@Sun.COM * MAJOR - This should only change when there is an incompatible change made
347836SJohn.Forte@Sun.COM * to the interfaces or the output.
357836SJohn.Forte@Sun.COM *
367836SJohn.Forte@Sun.COM * MINOR - This should change whenever there is a new command or new feature
377836SJohn.Forte@Sun.COM * with no incompatible change.
387836SJohn.Forte@Sun.COM */
397836SJohn.Forte@Sun.COM #define VERSION_STRING_MAJOR "1"
407836SJohn.Forte@Sun.COM #define VERSION_STRING_MINOR "0"
417836SJohn.Forte@Sun.COM
427836SJohn.Forte@Sun.COM #define OPTIONSTRING1 "HBA Port WWN"
437836SJohn.Forte@Sun.COM #define OPTIONSTRING2 "HBA Node WWN"
447836SJohn.Forte@Sun.COM /* forward declarations */
457836SJohn.Forte@Sun.COM static int listHbaPortFunc(int, char **, cmdOptions_t *, void *);
467836SJohn.Forte@Sun.COM static int listRemotePortFunc(int, char **, cmdOptions_t *, void *);
477836SJohn.Forte@Sun.COM static int listLogicalUnitFunc(int, char **, cmdOptions_t *, void *);
487836SJohn.Forte@Sun.COM static int npivCreatePortFunc(int, char **, cmdOptions_t *, void *);
497836SJohn.Forte@Sun.COM static int npivDeletePortFunc(int, char **, cmdOptions_t *, void *);
507836SJohn.Forte@Sun.COM static int npivCreatePortListFunc(int, char **, cmdOptions_t *, void *);
517836SJohn.Forte@Sun.COM static int npivListHbaPortFunc(int, char **, cmdOptions_t *, void *);
527836SJohn.Forte@Sun.COM static int npivListRemotePortFunc(int, char **, cmdOptions_t *, void *);
539087SZhong.Wang@Sun.COM static int fcoeAdmCreatePortFunc(int, char **, cmdOptions_t *, void *);
549087SZhong.Wang@Sun.COM static int fcoeListPortsFunc(int, char **, cmdOptions_t *, void *);
559087SZhong.Wang@Sun.COM static int fcoeAdmDeletePortFunc(int, char **, cmdOptions_t *, void *);
56*10275SReed.Liu@Sun.COM static int fcadmForceLipFunc(int, char **, cmdOptions_t *, void *);
577836SJohn.Forte@Sun.COM static char *getExecBasename(char *);
587836SJohn.Forte@Sun.COM
597836SJohn.Forte@Sun.COM /*
607836SJohn.Forte@Sun.COM * Add new options here
617836SJohn.Forte@Sun.COM *
627836SJohn.Forte@Sun.COM * Optional option-arguments are not allowed by CLIP
637836SJohn.Forte@Sun.COM */
647836SJohn.Forte@Sun.COM optionTbl_t fcinfolongOptions[] = {
657836SJohn.Forte@Sun.COM {"port", required_argument, 'p', OPTIONSTRING1},
667836SJohn.Forte@Sun.COM {"target", no_argument, 't', NULL},
677836SJohn.Forte@Sun.COM {"initiator", no_argument, 'i', NULL},
687836SJohn.Forte@Sun.COM {"linkstat", no_argument, 'l', NULL},
697836SJohn.Forte@Sun.COM {"scsi-target", no_argument, 's', NULL},
709087SZhong.Wang@Sun.COM {"fcoe", no_argument, 'e', NULL},
717836SJohn.Forte@Sun.COM {"verbose", no_argument, 'v', NULL},
727836SJohn.Forte@Sun.COM {NULL, 0, 0}
737836SJohn.Forte@Sun.COM };
747836SJohn.Forte@Sun.COM
757836SJohn.Forte@Sun.COM optionTbl_t fcadmlongOptions[] = {
767836SJohn.Forte@Sun.COM {"port", required_argument, 'p', OPTIONSTRING1},
777836SJohn.Forte@Sun.COM {"node", required_argument, 'n', OPTIONSTRING2},
787836SJohn.Forte@Sun.COM {"linkstat", no_argument, 'l', NULL},
797836SJohn.Forte@Sun.COM {"scsi-target", no_argument, 's', NULL},
809087SZhong.Wang@Sun.COM {"fcoe-force-promisc", no_argument, 'f', NULL},
819087SZhong.Wang@Sun.COM {"target", no_argument, 't', NULL},
8210264SZhong.Wang@Sun.COM {"initiator", no_argument, 'i', NULL},
837836SJohn.Forte@Sun.COM {NULL, 0, 0}
847836SJohn.Forte@Sun.COM };
857836SJohn.Forte@Sun.COM
867836SJohn.Forte@Sun.COM /*
877836SJohn.Forte@Sun.COM * Add new subcommands here
887836SJohn.Forte@Sun.COM */
897836SJohn.Forte@Sun.COM subCommandProps_t fcinfosubcommands[] = {
909087SZhong.Wang@Sun.COM {"hba-port", listHbaPortFunc, "itel", NULL, NULL,
917836SJohn.Forte@Sun.COM OPERAND_OPTIONAL_MULTIPLE, "WWN"},
927836SJohn.Forte@Sun.COM {"remote-port", listRemotePortFunc, "lsp", "p", NULL,
937836SJohn.Forte@Sun.COM OPERAND_OPTIONAL_MULTIPLE, "WWN"},
947836SJohn.Forte@Sun.COM {"logical-unit", listLogicalUnitFunc, "v", NULL, NULL,
957836SJohn.Forte@Sun.COM OPERAND_OPTIONAL_MULTIPLE, "OS Device Path"},
967836SJohn.Forte@Sun.COM {"lu", listLogicalUnitFunc, "v", NULL, NULL,
977836SJohn.Forte@Sun.COM OPERAND_OPTIONAL_MULTIPLE, "OS Device Path"},
987836SJohn.Forte@Sun.COM {NULL, 0, NULL, NULL, NULL, 0, NULL, NULL}
997836SJohn.Forte@Sun.COM };
1007836SJohn.Forte@Sun.COM
1017836SJohn.Forte@Sun.COM subCommandProps_t fcadmsubcommands[] = {
1027836SJohn.Forte@Sun.COM {"create-npiv-port",
1037836SJohn.Forte@Sun.COM npivCreatePortFunc, "pn", NULL, NULL,
1047836SJohn.Forte@Sun.COM OPERAND_MANDATORY_SINGLE, "WWN"},
1057836SJohn.Forte@Sun.COM {"delete-npiv-port",
1067836SJohn.Forte@Sun.COM npivDeletePortFunc, "p", "p", NULL,
1077836SJohn.Forte@Sun.COM OPERAND_MANDATORY_SINGLE, "WWN"},
1087836SJohn.Forte@Sun.COM {"hba-port",
1097836SJohn.Forte@Sun.COM npivListHbaPortFunc, "l", NULL, NULL,
1107836SJohn.Forte@Sun.COM OPERAND_OPTIONAL_MULTIPLE, "WWN"},
1117836SJohn.Forte@Sun.COM {"remote-port",
1127836SJohn.Forte@Sun.COM npivListRemotePortFunc, "psl", "p", NULL,
1137836SJohn.Forte@Sun.COM OPERAND_OPTIONAL_MULTIPLE, "WWN"},
1147836SJohn.Forte@Sun.COM {"create-port-list",
1157836SJohn.Forte@Sun.COM npivCreatePortListFunc, NULL, NULL, NULL,
1167836SJohn.Forte@Sun.COM OPERAND_NONE, NULL},
1179087SZhong.Wang@Sun.COM {"create-fcoe-port",
11810264SZhong.Wang@Sun.COM fcoeAdmCreatePortFunc, "itpnf", NULL, NULL,
1199087SZhong.Wang@Sun.COM OPERAND_MANDATORY_SINGLE, "Network Interface Name"},
1209087SZhong.Wang@Sun.COM {"delete-fcoe-port",
1219087SZhong.Wang@Sun.COM fcoeAdmDeletePortFunc, NULL, NULL, NULL,
1229087SZhong.Wang@Sun.COM OPERAND_MANDATORY_SINGLE, "Network Interface Name"},
1239087SZhong.Wang@Sun.COM {"list-fcoe-ports",
12410264SZhong.Wang@Sun.COM fcoeListPortsFunc, "it", NULL, NULL,
1259087SZhong.Wang@Sun.COM OPERAND_NONE, NULL},
126*10275SReed.Liu@Sun.COM {"force-lip",
127*10275SReed.Liu@Sun.COM fcadmForceLipFunc, NULL, NULL, NULL,
128*10275SReed.Liu@Sun.COM OPERAND_MANDATORY_SINGLE, "WWN"},
1297836SJohn.Forte@Sun.COM {NULL, 0, NULL, NULL, NULL, 0, NULL, NULL}
1307836SJohn.Forte@Sun.COM };
1319087SZhong.Wang@Sun.COM
1327836SJohn.Forte@Sun.COM /*
1337836SJohn.Forte@Sun.COM * Pass in options/arguments, rest of arguments
1347836SJohn.Forte@Sun.COM */
1357836SJohn.Forte@Sun.COM /*ARGSUSED*/
1367836SJohn.Forte@Sun.COM static int
listHbaPortFunc(int objects,char * argv[],cmdOptions_t * options,void * addArgs)1377836SJohn.Forte@Sun.COM listHbaPortFunc(int objects, char *argv[], cmdOptions_t *options, void *addArgs)
1387836SJohn.Forte@Sun.COM {
1397836SJohn.Forte@Sun.COM return (fc_util_list_hbaport(objects, argv, options));
1407836SJohn.Forte@Sun.COM }
1417836SJohn.Forte@Sun.COM
1427836SJohn.Forte@Sun.COM /*
1437836SJohn.Forte@Sun.COM * Pass in options/arguments, rest of arguments
1447836SJohn.Forte@Sun.COM */
1457836SJohn.Forte@Sun.COM /*ARGSUSED*/
1467836SJohn.Forte@Sun.COM static int
listRemotePortFunc(int objects,char * argv[],cmdOptions_t * options,void * addArgs)1477836SJohn.Forte@Sun.COM listRemotePortFunc(int objects, char *argv[], cmdOptions_t *options,
1487836SJohn.Forte@Sun.COM void *addArgs)
1497836SJohn.Forte@Sun.COM {
1507836SJohn.Forte@Sun.COM return (fc_util_list_remoteport(objects, argv, options));
1517836SJohn.Forte@Sun.COM }
1527836SJohn.Forte@Sun.COM
1537836SJohn.Forte@Sun.COM /*
1547836SJohn.Forte@Sun.COM * Pass in options/arguments, rest of arguments
1557836SJohn.Forte@Sun.COM */
1567836SJohn.Forte@Sun.COM /*ARGSUSED*/
1577836SJohn.Forte@Sun.COM static int
listLogicalUnitFunc(int objects,char * argv[],cmdOptions_t * options,void * addArgs)1587836SJohn.Forte@Sun.COM listLogicalUnitFunc(int objects, char *argv[], cmdOptions_t *options,
1597836SJohn.Forte@Sun.COM void *addArgs)
1607836SJohn.Forte@Sun.COM {
1617836SJohn.Forte@Sun.COM return (fc_util_list_logicalunit(objects, argv, options));
1627836SJohn.Forte@Sun.COM }
1637836SJohn.Forte@Sun.COM
1647836SJohn.Forte@Sun.COM /*
1657836SJohn.Forte@Sun.COM * Pass in options/arguments, rest of arguments
1667836SJohn.Forte@Sun.COM */
1677836SJohn.Forte@Sun.COM /*ARGSUSED*/
1687836SJohn.Forte@Sun.COM static int
npivCreatePortFunc(int objects,char * argv[],cmdOptions_t * options,void * addArgs)1697836SJohn.Forte@Sun.COM npivCreatePortFunc(int objects, char *argv[],
1707836SJohn.Forte@Sun.COM cmdOptions_t *options, void *addArgs) {
1717836SJohn.Forte@Sun.COM return (fc_util_create_npivport(objects, argv, options));
1727836SJohn.Forte@Sun.COM }
1737836SJohn.Forte@Sun.COM
1747836SJohn.Forte@Sun.COM static int
npivCreatePortListFunc(int objects,char * argv[],cmdOptions_t * options,void * addArgs)1757836SJohn.Forte@Sun.COM npivCreatePortListFunc(int objects, char *argv[],
1767836SJohn.Forte@Sun.COM cmdOptions_t *options, void *addArgs) {
1777836SJohn.Forte@Sun.COM if ((objects == 0) && addArgs && options && argv) {
1787836SJohn.Forte@Sun.COM objects = 1;
1797836SJohn.Forte@Sun.COM }
1807836SJohn.Forte@Sun.COM return (fc_util_create_portlist());
1817836SJohn.Forte@Sun.COM }
1827836SJohn.Forte@Sun.COM
1837836SJohn.Forte@Sun.COM /*
1847836SJohn.Forte@Sun.COM * Pass in options/arguments, rest of arguments
1857836SJohn.Forte@Sun.COM */
1867836SJohn.Forte@Sun.COM /*ARGSUSED*/
1877836SJohn.Forte@Sun.COM static int
npivDeletePortFunc(int objects,char * argv[],cmdOptions_t * options,void * addArgs)1887836SJohn.Forte@Sun.COM npivDeletePortFunc(int objects, char *argv[],
1897836SJohn.Forte@Sun.COM cmdOptions_t *options, void *addArgs) {
1907836SJohn.Forte@Sun.COM return (fc_util_delete_npivport(objects, argv, options));
1917836SJohn.Forte@Sun.COM }
1927836SJohn.Forte@Sun.COM
1937836SJohn.Forte@Sun.COM /*
1947836SJohn.Forte@Sun.COM * Pass in options/arguments, rest of arguments
1957836SJohn.Forte@Sun.COM */
1967836SJohn.Forte@Sun.COM /*ARGSUSED*/
1977836SJohn.Forte@Sun.COM static int
npivListHbaPortFunc(int objects,char * argv[],cmdOptions_t * options,void * addArgs)1987836SJohn.Forte@Sun.COM npivListHbaPortFunc(int objects, char *argv[],
1997836SJohn.Forte@Sun.COM cmdOptions_t *options, void *addArgs) {
2007836SJohn.Forte@Sun.COM return (fc_util_list_hbaport(objects, argv, options));
2017836SJohn.Forte@Sun.COM }
2027836SJohn.Forte@Sun.COM
2037836SJohn.Forte@Sun.COM /*
2047836SJohn.Forte@Sun.COM * Pass in options/arguments, rest of arguments
2057836SJohn.Forte@Sun.COM */
2067836SJohn.Forte@Sun.COM /*ARGSUSED*/
2077836SJohn.Forte@Sun.COM static int
npivListRemotePortFunc(int objects,char * argv[],cmdOptions_t * options,void * addArgs)2087836SJohn.Forte@Sun.COM npivListRemotePortFunc(int objects, char *argv[],
2097836SJohn.Forte@Sun.COM cmdOptions_t *options, void *addArgs) {
2107836SJohn.Forte@Sun.COM return (fc_util_list_remoteport(objects, argv, options));
2117836SJohn.Forte@Sun.COM }
2127836SJohn.Forte@Sun.COM
2137836SJohn.Forte@Sun.COM /*
2149087SZhong.Wang@Sun.COM * Pass in options/arguments, rest of arguments
2159087SZhong.Wang@Sun.COM */
2169087SZhong.Wang@Sun.COM /*ARGSUSED*/
2179087SZhong.Wang@Sun.COM static int
fcoeAdmCreatePortFunc(int objects,char * argv[],cmdOptions_t * options,void * addArgs)2189087SZhong.Wang@Sun.COM fcoeAdmCreatePortFunc(int objects, char *argv[], cmdOptions_t *options,
2199087SZhong.Wang@Sun.COM void *addArgs)
2209087SZhong.Wang@Sun.COM {
2219087SZhong.Wang@Sun.COM return (fcoe_adm_create_port(objects, argv, options));
2229087SZhong.Wang@Sun.COM }
2239087SZhong.Wang@Sun.COM
2249087SZhong.Wang@Sun.COM /*
2259087SZhong.Wang@Sun.COM * Pass in options/arguments, rest of arguments
2269087SZhong.Wang@Sun.COM */
2279087SZhong.Wang@Sun.COM /*ARGSUSED*/
2289087SZhong.Wang@Sun.COM static int
fcoeAdmDeletePortFunc(int objects,char * argv[],cmdOptions_t * options,void * addArgs)2299087SZhong.Wang@Sun.COM fcoeAdmDeletePortFunc(int objects, char *argv[], cmdOptions_t *options,
2309087SZhong.Wang@Sun.COM void *addArgs)
2319087SZhong.Wang@Sun.COM {
2329087SZhong.Wang@Sun.COM return (fcoe_adm_delete_port(objects, argv));
2339087SZhong.Wang@Sun.COM }
2349087SZhong.Wang@Sun.COM
2359087SZhong.Wang@Sun.COM /*
2369087SZhong.Wang@Sun.COM * Pass in options/arguments, rest of arguments
2379087SZhong.Wang@Sun.COM */
2389087SZhong.Wang@Sun.COM /*ARGSUSED*/
2399087SZhong.Wang@Sun.COM static int
fcoeListPortsFunc(int objects,char * argv[],cmdOptions_t * options,void * addArgs)2409087SZhong.Wang@Sun.COM fcoeListPortsFunc(int objects, char *argv[], cmdOptions_t *options,
2419087SZhong.Wang@Sun.COM void *addArgs)
2429087SZhong.Wang@Sun.COM {
2439087SZhong.Wang@Sun.COM return (fcoe_adm_list_ports(options));
2449087SZhong.Wang@Sun.COM }
2459087SZhong.Wang@Sun.COM
2469087SZhong.Wang@Sun.COM /*
247*10275SReed.Liu@Sun.COM * Pass in options/arguments, rest of arguments
248*10275SReed.Liu@Sun.COM */
249*10275SReed.Liu@Sun.COM /*ARGSUSED*/
250*10275SReed.Liu@Sun.COM static int
fcadmForceLipFunc(int objects,char * argv[],cmdOptions_t * options,void * addArgs)251*10275SReed.Liu@Sun.COM fcadmForceLipFunc(int objects, char *argv[], cmdOptions_t *options,
252*10275SReed.Liu@Sun.COM void *addArgs)
253*10275SReed.Liu@Sun.COM {
254*10275SReed.Liu@Sun.COM return (fc_util_force_lip(objects, argv));
255*10275SReed.Liu@Sun.COM }
256*10275SReed.Liu@Sun.COM
257*10275SReed.Liu@Sun.COM /*
2587836SJohn.Forte@Sun.COM * input:
2597836SJohn.Forte@Sun.COM * execFullName - exec name of program (argv[0])
2607836SJohn.Forte@Sun.COM *
2617836SJohn.Forte@Sun.COM * Returns:
2627836SJohn.Forte@Sun.COM * command name portion of execFullName
2637836SJohn.Forte@Sun.COM */
2647836SJohn.Forte@Sun.COM static char *
getExecBasename(char * execFullname)2657836SJohn.Forte@Sun.COM getExecBasename(char *execFullname)
2667836SJohn.Forte@Sun.COM {
2677836SJohn.Forte@Sun.COM char *lastSlash, *execBasename;
2687836SJohn.Forte@Sun.COM
2697836SJohn.Forte@Sun.COM /* guard against '/' at end of command invocation */
2707836SJohn.Forte@Sun.COM for (;;) {
2717836SJohn.Forte@Sun.COM lastSlash = strrchr(execFullname, '/');
2727836SJohn.Forte@Sun.COM if (lastSlash == NULL) {
2737836SJohn.Forte@Sun.COM execBasename = execFullname;
2747836SJohn.Forte@Sun.COM break;
2757836SJohn.Forte@Sun.COM } else {
2767836SJohn.Forte@Sun.COM execBasename = lastSlash + 1;
2777836SJohn.Forte@Sun.COM if (*execBasename == '\0') {
2787836SJohn.Forte@Sun.COM *lastSlash = '\0';
2797836SJohn.Forte@Sun.COM continue;
2807836SJohn.Forte@Sun.COM }
2817836SJohn.Forte@Sun.COM break;
2827836SJohn.Forte@Sun.COM }
2837836SJohn.Forte@Sun.COM }
2847836SJohn.Forte@Sun.COM return (execBasename);
2857836SJohn.Forte@Sun.COM }
2867836SJohn.Forte@Sun.COM
2877836SJohn.Forte@Sun.COM /*
2887836SJohn.Forte@Sun.COM * main calls a parser that checks syntax of the input command against
2897836SJohn.Forte@Sun.COM * various rules tables.
2907836SJohn.Forte@Sun.COM *
2917836SJohn.Forte@Sun.COM * The parser provides usage feedback based upon same tables by calling
2927836SJohn.Forte@Sun.COM * two usage functions, usage and subUsage, handling command and subcommand
2937836SJohn.Forte@Sun.COM * usage respectively.
2947836SJohn.Forte@Sun.COM *
2957836SJohn.Forte@Sun.COM * The parser handles all printing of usage syntactical errors
2967836SJohn.Forte@Sun.COM *
2977836SJohn.Forte@Sun.COM * When syntax is successfully validated, the parser calls the associated
2987836SJohn.Forte@Sun.COM * function using the subcommands table functions.
2997836SJohn.Forte@Sun.COM *
3007836SJohn.Forte@Sun.COM * Syntax is as follows:
3017836SJohn.Forte@Sun.COM * command subcommand [options] resource-type [<object>]
3027836SJohn.Forte@Sun.COM *
3037836SJohn.Forte@Sun.COM * The return value from the function is placed in funcRet
3047836SJohn.Forte@Sun.COM */
3057836SJohn.Forte@Sun.COM int
main(int argc,char * argv[])3067836SJohn.Forte@Sun.COM main(int argc, char *argv[])
3077836SJohn.Forte@Sun.COM {
3087836SJohn.Forte@Sun.COM synTables_t synTables;
3097836SJohn.Forte@Sun.COM char versionString[VERSION_STRING_MAX_LEN];
3107836SJohn.Forte@Sun.COM int ret;
3117836SJohn.Forte@Sun.COM int funcRet;
3127836SJohn.Forte@Sun.COM void *subcommandArgs = NULL;
3137836SJohn.Forte@Sun.COM
3149087SZhong.Wang@Sun.COM (void) setlocale(LC_ALL, "");
3159087SZhong.Wang@Sun.COM #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
3169087SZhong.Wang@Sun.COM #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it weren't */
3179087SZhong.Wang@Sun.COM #endif
3189087SZhong.Wang@Sun.COM (void) textdomain(TEXT_DOMAIN);
3199087SZhong.Wang@Sun.COM
3207836SJohn.Forte@Sun.COM /* set global command name */
3217836SJohn.Forte@Sun.COM cmdName = getExecBasename(argv[0]);
3227836SJohn.Forte@Sun.COM
3237836SJohn.Forte@Sun.COM sprintf(versionString, "%s.%s",
3247836SJohn.Forte@Sun.COM VERSION_STRING_MAJOR, VERSION_STRING_MINOR);
3257836SJohn.Forte@Sun.COM synTables.versionString = versionString;
3267836SJohn.Forte@Sun.COM if (strcmp(cmdName, "fcadm") == 0) {
3277836SJohn.Forte@Sun.COM synTables.longOptionTbl = &fcadmlongOptions[0];
3287836SJohn.Forte@Sun.COM synTables.subCommandPropsTbl = &fcadmsubcommands[0];
3297836SJohn.Forte@Sun.COM } else {
3307836SJohn.Forte@Sun.COM synTables.longOptionTbl = &fcinfolongOptions[0];
3317836SJohn.Forte@Sun.COM synTables.subCommandPropsTbl = &fcinfosubcommands[0];
3327836SJohn.Forte@Sun.COM }
3337836SJohn.Forte@Sun.COM
3347836SJohn.Forte@Sun.COM /* call the CLI parser */
3357836SJohn.Forte@Sun.COM ret = cmdParse(argc, argv, synTables, subcommandArgs, &funcRet);
3367836SJohn.Forte@Sun.COM if (ret == 1) {
3377836SJohn.Forte@Sun.COM fprintf(stdout, "%s %s(1M)\n",
3387836SJohn.Forte@Sun.COM gettext("For more information, please see"), cmdName);
3397836SJohn.Forte@Sun.COM return (1);
3407836SJohn.Forte@Sun.COM } else if (ret == -1) {
3417836SJohn.Forte@Sun.COM perror(cmdName);
3427836SJohn.Forte@Sun.COM return (1);
3437836SJohn.Forte@Sun.COM }
3447836SJohn.Forte@Sun.COM
3457836SJohn.Forte@Sun.COM if (funcRet != 0) {
3467836SJohn.Forte@Sun.COM return (1);
3477836SJohn.Forte@Sun.COM }
3487836SJohn.Forte@Sun.COM return (0);
3497836SJohn.Forte@Sun.COM }
350